public IActionResult EditPost(DeliveryItemOperVM model, string filterJson) { if (filterJson == null) { var deliveryItem = itemService.getDeliveryItem(model.DeliveryItemId); ViewBag.notificationId = deliveryItem.CaseNotificationId; ViewBag.breadcrumbs = commonService.Breadcrumbs_ForCaseNotificationDeliveryOperEdit(deliveryItem.CaseNotificationId ?? 0, 0).DeleteOrDisableLast(); } else { int filterType = getFilterTypeFromJson(filterJson); ViewBag.breadcrumbs = commonService.Breadcrumbs_ForDeliveryItemAddOper(filterType, model.DeliveryItemId).DeleteOrDisableLast(); } ViewBag.filterJson = filterJson; SetViewbag(model.DeliveryOperId); ValidateModel(model); if (!ModelState.IsValid) { return(View(nameof(Edit), model)); } var currentId = model.Id; if (itemService.DeliveryItemSaveOper(model)) { this.SaveLogOperation(currentId == 0, model.Id); ModelState.Clear(); SetSuccessMessage(MessageConstant.Values.SaveOK); return(View(nameof(Edit), model)); } else { SetErrorMessage(MessageConstant.Values.SaveFailed); } return(View(nameof(Edit), model)); }
public IActionResult EditPost(DeliveryItemOperVM model, string filterJson) { var deliveryItem = itemService.getDeliveryItem(model.DeliveryItemId); ViewBag.notificationId = deliveryItem.CaseNotificationId; if (filterJson == null) { ViewBag.breadcrumbs = commonService.Breadcrumbs_ForCaseNotificationDeliveryOperEdit(deliveryItem.CaseNotificationId ?? 0, 0).DeleteOrDisableLast(); } else { int filterType = getFilterTypeFromJson(filterJson); ViewBag.breadcrumbs = commonService.Breadcrumbs_ForDeliveryItemAddOper(filterType, model.DeliveryItemId).DeleteOrDisableLast(); } ViewBag.filterJson = filterJson; SetViewbag(model.DeliveryOperId); ValidateModel(model); if (!ModelState.IsValid) { return(View(nameof(Edit), model)); } bool isInsert = !service.HaveSameOper(model.DeliveryItemId, model.DeliveryOperId); if (itemService.DeliveryItemSaveOper(model)) { SaveLogOperation(isInsert, $"{model.DeliveryItemId}|NEW"); ModelState.Clear(); SetSuccessMessage(MessageConstant.Values.SaveOK); if (filterJson != null) { // return LoadIndex(model.DeliveryItemId, filterJson); // TempData["filterJson"] = filterJson; // return RedirectToAction("EditReturn", "DeliveryItem", new { deliveryItemId = model.DeliveryItemId }); return(View(nameof(Edit), model)); } else { return(RedirectToAction(nameof(Index), new { notificationId = deliveryItem.CaseNotificationId })); } } else { SetErrorMessage(MessageConstant.Values.SaveFailed); } return(View(nameof(Edit), model)); }