public ActionResult Update(PORModels.UpdateCustody Model) { var errorList = new List <string>(); if (ModelState.IsValid) { int status = db.UpdateCustodyProcurement(Model.ItemID, Model.ArrivalDate, Model.RequestedDate, DateTime.Now, Model.DeliveredDate, Model.LocationID, Model.PackingSlipNumber, Model.SerialNumber); db.SaveChanges(); if (status == 1) { return(Json(new { status = "success" })); } else { errorList.Add("Custody couldn't be updated. Please retry."); } } errorList.AddRange((from item in ModelState.Values from error in item.Errors select error.ErrorMessage).ToList() ); return(Json(new { status = "error", errors = errorList })); }
public ActionResult Update(int?id) { var item = db.GetUpdateInfoByItemID(id).FirstOrDefault(); if (item == null) { return(HttpNotFound()); } var model = new PORModels.UpdateCustody() { ItemID = item.ViewID, PORNumber = item.Por_, Vendor = item.Vendor, Manufacturer = item.Manufacturer, Model = item.Model, ProductDescription = item.ProductDescription, ArrivalDate = item.Arrival, RequestedDate = item.Requested, DeliveredDate = item.Delivered, ActualCost = item.ActCost, LocationID = item.LocationID, PackingSlipNumber = item.Packing_, SerialNumber = item.Serial_ }; ViewBag.Locations = new SelectList(db.GetCustodyLocationsBySiteCoID(siteusercompanyid).ToList(), nameof(GetCustodyLocationsBySiteCoID_Result.ViewID), nameof(GetCustodyLocationsBySiteCoID_Result.Name), item.LocationID); return(View(model)); }
public ActionResult UpdateSelected(PORModels.UpdateCustody Model, string PorItemIDs) { var errorList = new List <string>(); var porItemIDsInt = new List <int>(); try { porItemIDsInt = PorItemIDs.Split(',').Select(p => Convert.ToInt32(p)).ToList(); } catch (Exception ex) { LogRepository.LogException(ex); } if (ModelState.IsValid) { foreach (int itemid in porItemIDsInt) { var item = db.GetUpdateInfoByItemID((int?)itemid).FirstOrDefault(); int status = db.UpdateCustodyProcurement(itemid, Model.ArrivalDate, item.Requested, DateTime.Now, Model.DeliveredDate, Model.LocationID, Model.PackingSlipNumber, item.Serial_); db.SaveChanges(); if (status == 1) { return(Json(new { status = "success" })); } else { errorList.Add("Custody couldn't be updated. Please retry."); } } } errorList.AddRange((from item in ModelState.Values from error in item.Errors select error.ErrorMessage).ToList() ); return(Json(new { status = "error", errors = errorList })); }