Example #1
0
        public IActionResult EditResult(CaseSessionResult model)
        {
            SetViewbagResult(model.CaseSessionId);
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }

            string _isvalid = IsValidResult(model);

            if (_isvalid != string.Empty)
            {
                SetErrorMessage(_isvalid);
                return(View(nameof(EditResult), model));
            }

            var currentId = model.Id;

            if (service.CaseSessionResult_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseSessionResult, model.Id, currentId == 0);
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction(nameof(EditResult), new { id = model.Id }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }

            return(View(nameof(EditResult), model));
        }
        public IActionResult EditResult(CaseSessionResultEditVM model)
        {
            SetViewbagResult(model.CaseSessionId);
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }

            string _isvalid = IsValidResult(model);

            if (_isvalid != string.Empty)
            {
                SetErrorMessage(_isvalid);
                return(View(nameof(EditResult), model));
            }

            var currentId = model.Id;

            if (service.CaseSessionResult_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseSessionResult, model.Id, currentId == 0);
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);

                if ((model.SessionResultId == NomenclatureConstants.CaseSessionResult.S_opredelenie_za_otvod) ||
                    (model.SessionResultId == NomenclatureConstants.CaseSessionResult.S_razporejdane_za_otvod))
                {
                    if (currentId == 0)
                    {
                        if (model.CaseLawUnitByCase != null)
                        {
                            var check = model.CaseLawUnitByCase.Where(x => x.Checked).FirstOrDefault();
                            if (check != null)
                            {
                                return(RedirectToAction("AddEditDismisal", "CaseLawUnit", new { lawUnitId = int.Parse(check.Value) }));
                            }
                        }
                    }
                }

                if (model.CallFromActId > 0)
                {
                    return(RedirectToAction("Edit", "CaseSessionAct", new { id = model.CallFromActId }));
                }
                else
                {
                    return(RedirectToAction(nameof(Preview), new { id = model.CaseSessionId }));
                }
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }

            return(View(nameof(EditResult), model));
        }