0

I have an opening page which lets user to enter SupervisorList page

<li>
  <a href="/Moderation/SupervisorList?StartTime=@DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd")&EndTime=@DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")">
                            <i class="icon-legal"></i>
                            Supervisor List
  </a>
</li>

After entering this page, user may change StartTime and EndTime submit a form via this function:

function acceptDenyFinalBtn() {
             $('#FlowCatId').val($("#modalFlowCatList").val());
             $('#ModCategoryId').val($("#modalModCategory").val());
             $('#PositiveInd').val($("#modalPositiveInd").val());

             $('#ContentForm').submit();
         }

And here is the submit action in controller:

public ActionResult SubmitModSupervised(Content model)
        {
            string status = "";

            status = ModerationBLL.ContentStatus.MODERATIONCOMPLETE.ToString();

            ModerationDM.Content updateContent = contentBLL.GetContent(model.ModId, model.ContentSeqNum);

            if (updateContent.Status != ContentStatus.MODERATIONCOMPLETE.ToString())
            {
                updateContent.ModifiedTime = DateTime.Now;
            }

            updateContent.ResultCode = model.ResultCode;
            updateContent.Status = status;
            updateContent.ModCategoryId = model.ModCategoryId;
            updateContent.PositiveInd = model.PositiveInd;
            updateContent.ModUserName = ((ModerationDM.User)Session["UserProfile"]).UserName;

            contentBLL.UpdateContent(updateContent);

            TempData["Notification Type"] = "S";


            return RedirectToAction("SupervisorList", "Moderation", new { StartTime=DateTime.Now.AddDays(-2).Date, EndTime=DateTime.Now.AddDays(1) });
        }

As you can see in last line, I redirect to SupervisorList action again, but this time with new StartTime and EndTime. What I'm trying to do is to keep the chosen StartTime and EndTime if the user changed it. How can I achieve this?

Burak Karakuş
  • 1,368
  • 5
  • 20
  • 43
  • 1
    If you added the previous start & end time to the `Content` model, you could add them as hidden fields in the `SupervisorList` View and they would be submitted to `SubmitModSupervised` with the form data. – markpsmith Jul 07 '14 at 09:42
  • StartTime and EndTime are not defined in `Content` model. They are in another model. Thanks though. – Burak Karakuş Jul 07 '14 at 09:47
  • 1
    The only ways to pass the entered values to the `SubmitModSupervised` method are either via Query String parameters, or via hidden fields as `markpsmith` suggested. Do not be shy about changing your `Content` model (or sub-classing it) as that is the best solution. – iCollect.it Ltd Jul 07 '14 at 14:32
  • Hidden fields solved my problem, thanks for both of yours effort. – Burak Karakuş Jul 07 '14 at 14:49

0 Answers0