Пример #1
0
        public IActionResult EditStatePost(DeliveryItem model, string filterJson)
        {
            ViewBag.filterJson = filterJson;
            var notification = notificationService.GetById <CaseNotification>(model.CaseNotificationId);

            if (!ModelState.IsValid)
            {
                SetViewbagState(notification?.NotificationDeliveryGroupId ?? -1);
                return(View(nameof(EditState), model));
            }

            if (service.DeliveryItemSaveState(model.Id, model.NotificationStateId, model.DeliveryDateCC))
            {
                this.SaveLogOperation(false, model.Id);
                return(RedirectToAction(nameof(EditState), new { id = model.Id, filterJson }));
            }
            else
            {
                int filterType = getFilterTypeFromJson(filterJson);
                ViewBag.breadcrumbs = commonService.Breadcrumbs_ForDeliveryItemEditReturn(filterType, model.Id).DeleteOrDisableLast();
                SetViewbagState(notification?.NotificationDeliveryGroupId ?? -1);
                SetErrorMessage(MessageConstant.Values.SaveFailed);
                return(View(nameof(EditState), model));
            }
        }
        public IActionResult EditStatePost(DeliveryItem model, string filterJson)
        {
            ViewBag.filterJson = filterJson;
            var notification = notificationService.GetById <CaseNotification>(model.CaseNotificationId);

            if (model.DeliveryDateCC < model.RegDate?.Date)
            {
                ModelState.AddModelError(nameof(model.DeliveryDateCC), $"{MessageConstant.ValidationErrors.DeliveryDateBeforeRegDate} {model.RegDate?.ToString(FormattingConstant.NormalDateFormat)}");
            }
            if (model.DeliveryDateCC > DateTime.Now.AddMinutes(10))
            {
                ModelState.AddModelError(nameof(model.DeliveryDateCC), MessageConstant.ValidationErrors.DeliveryDateFuture);
            }
            if (!ModelState.IsValid)
            {
                SetViewbagState(notification?.NotificationDeliveryGroupId ?? -1);
                return(View(nameof(EditState), model));
            }

            if (service.DeliveryItemSaveState(model.Id, model.NotificationStateId, model.DeliveryDateCC, model.DeliveryInfo))
            {
                this.SaveLogOperation(false, model.Id);
                return(RedirectToAction(nameof(EditState), new { id = model.Id, filterJson }));
            }
            else
            {
                int filterType = getFilterTypeFromJson(filterJson);
                ViewBag.breadcrumbs = commonService.Breadcrumbs_ForDeliveryItemEditReturn(filterType, model.Id).DeleteOrDisableLast();
                SetViewbagState(notification?.NotificationDeliveryGroupId ?? -1);
                SetErrorMessage(MessageConstant.Values.SaveFailed);
                return(View(nameof(EditState), model));
            }
        }