Ejemplo n.º 1
0
        public IActionResult Edit(CaseEditVM model)
        {
            SetViewBagEdit(model);

            ValidateCaseEdit(model);
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }

            var currentId = model.Id;
            var isInsert  = string.IsNullOrEmpty(model.RegNumber);

            if (service.Case_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.Case, model.Id, currentId == 0);
                this.SaveLogOperation(isInsert, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction(nameof(Edit), new { id = model.Id }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }
            return(View(nameof(Edit), model));
        }