コード例 #1
0
        public ActionResult BatchUpdateForReqShelters(MVCxGridViewBatchUpdateValues <ShelterRequest, int> updatedProducts, 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.RecommendShelters(updatedProducts);
                    model = GetRequestModel(reqId);
                    return(PartialView("Grid/_ReqShelterGrid", model.Shelters));
                }
                catch (Exception e)
                {
                    TempData["ErrorMessage"] = e.Message;
                    Logger.LogError(e, "Error while recommending shelters for request from Supervisor zone");
                    BaseRepository.OimsDataContext.ClearChanges(); // Roll back all changes
                }
            }
            else
            {
                TempData["ErrorMessage"] = "Please, correct all errors.";
            }

            // If reached here, show errors
            model = GetRequestModel(reqId);
            return(PartialView("Grid/_ReqShelterGrid", model.Shelters));
        }