Example #1
0
        public ActionResult BatchUpdateForReqItems(MVCxGridViewBatchUpdateValues <ItemRequest, int> updatedItems, string status)
        {
            RequestDetailModel model;

            Session["Status"] = ViewData["Status"] = status; // To show batchEdit commands
            var reqId = Session["ReqId"] != null?int.Parse(Convert.ToString(Session["ReqId"])) : 0;

            if (ModelState.IsValid)
            {
                try
                {
                    RequestsRepository.RecommendItems(updatedItems);
                    model = GetRequestModel(reqId);
                    return(PartialView("Grid/_ReqItemGrid", model.Items));
                }
                catch (Exception e)
                {
                    TempData["ErrorMessage"] = e.ToString();
                    BaseRepository.OimsDataContext.ClearChanges(); // Roll back all changes
                    Logger.LogError(e, "Error while recommending items for request from Supervisor zone");
                }
            }
            else
            {
                TempData["ErrorMessage"] = "Please, correct all errors.";
            }

            model = GetRequestModel(reqId);
            return(PartialView("Grid/_ReqItemGrid", model.Items));
        }