コード例 #1
0
        public IActionResult Edit(CaseSelectionProtokolVM model)
        {
            bool ExitByTime = false;

            SetViewBag(model.CourtId, model.CaseId);
            ViewBag.RoleId = model.JudgeRoleId;
            ValidateModel(model);


            if (!ModelState.IsValid)
            {
                SetDataError(model);
                return(View(nameof(Edit), model));
            }
            var    currentId    = model.Id;
            string errorMessage = "";
            bool   save         = true;

            if (NomenclatureConstants.JudgeRole.JuriRolesList.Contains(model.JudgeRoleId))
            {
                int protokolId = service.Select_Create_AddJuryProtocol(model, ref errorMessage);
                if (protokolId > 0)
                {
                    model.Id = protokolId;
                    return(RedirectToAction("SignDoc", new { id = model.Id }));
                }
                else
                {
                    save = false;
                }
            }
            else
            {
                ///////////////////////////////////////////////////////////////////////////////
                ///Взема се номер и се коригира
                ///
                /////////////////////////////////////////////////////////////////////////////////
                ///////////////Denislav Angelov 2020.08.27
                //int currentLockNumber = service.TakeCaseSelectionProtocolLockNumber(model.CourtGroupId, model.CourtDutyId);
                //Random rnd = new Random();
                //int ms = rnd.Next(100);
                //Thread.Sleep(ms);
                //int minLockNumber = service.TakeCaseSelectionProtocolMinLockNumber(model.CourtGroupId, model.CourtDutyId);
                //DateTime timeStart = DateTime.Now;

                //while (currentLockNumber != minLockNumber)
                //{
                //  Thread.Sleep(100);
                //  minLockNumber = service.TakeCaseSelectionProtocolMinLockNumber(model.CourtGroupId, model.CourtDutyId);
                //  if (timeStart.AddSeconds(60)<DateTime.Now)
                //  {
                //    ExitByTime = true;
                //    break;
                //  }
                //}
                //if (ExitByTime==false)
                //{
                //  if (service.HsaUnsignedProtocol(model.CaseId))
                //  {
                //    SetErrorMessage("Не може да бъде създаден нов протокол, докато има неподписан такъв.");
                //    return RedirectToAction("Index", new { id = model.CaseId });
                //  }
                ///////////////Denislav Angelov 2020.08.27
                if (!service.CaseSelectionProtokol_SaveData(model, ref errorMessage))
                {
                    save = false;
                }
                ///////////////Denislav Angelov 2020.08.27
                //}
                //else
                //{
                //  save = false;
                //}

                //service.FinishLockNumber(currentLockNumber);
                ///////////////Denislav Angelov 2020.08.27
                ///////////////////////////////////////////////////////////////////////////////
            }

            if (save == true)
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseSelectionProtokol, model.Id, currentId == 0);
                //this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
            }
            else
            {
                if (errorMessage == "")
                {
                    errorMessage = MessageConstant.Values.SaveFailed;
                }
                if (ExitByTime)
                {
                    errorMessage = MessageConstant.Values.TimeoutSelectProtokol;
                }
                SetErrorMessage(errorMessage);
                SetDataError(model);

                return(View(nameof(Edit), model));
            }
            //В случай няма наличен състав се отива на подпис

            var saved_model           = service.CaseSelectionProtokol_Preview(model.Id);
            var comparentmentLisCount = service.GetJudgeComprentmetList((saved_model.SelectedLawUnitId ?? 0), saved_model.CourtId, saved_model.CaseId).Count;

            if (comparentmentLisCount > 1)
            {
                return(RedirectToAction("PreviewDoc", new { id = model.Id }));
            }
            else
            {
                var res = service.CaseSelectionProtokol_UpdateBeforeDocForSign(saved_model);
                return(RedirectToAction("SignDoc", new { id = saved_model.Id }));
            }

            //    return RedirectToAction("PreviewDoc", new { id = model.Id });
        }
コード例 #2
0
        public IActionResult Edit(CaseSelectionProtokolVM model)
        {
            bool ExitByTime = false;

            SetViewBag(model.CourtId, model.CaseId);
            ViewBag.RoleId = model.JudgeRoleId;
            ValidateModel(model);


            if (!ModelState.IsValid)
            {
                SetDataError(model);
                return(View(nameof(Edit), model));
            }
            var    currentId    = model.Id;
            string errorMessage = "";
            bool   save         = true;

            if (NomenclatureConstants.JudgeRole.JuriRolesList.Contains(model.JudgeRoleId))
            {
                int protokolId = service.Select_Create_AddJuryProtocol(model, ref errorMessage);
                if (protokolId > 0)
                {
                    model.Id = protokolId;
                    return(RedirectToAction("SignDoc", new { id = model.Id }));
                }
                else
                {
                    save = false;
                }
            }
            else
            {
                if (!service.CaseSelectionProtokol_SaveData(model, ref errorMessage))
                {
                    save = false;
                }
            }

            if (save == true)
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseSelectionProtokol, model.Id, currentId == 0);
                //this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
            }
            else
            {
                if (errorMessage == "")
                {
                    errorMessage = MessageConstant.Values.SaveFailed;
                }
                if (ExitByTime)
                {
                    errorMessage = MessageConstant.Values.TimeoutSelectProtokol;
                }
                SetErrorMessage(errorMessage);
                SetDataError(model);

                return(View(nameof(Edit), model));
            }
            //В случай няма наличен състав се отива на подпис

            var saved_model           = service.CaseSelectionProtokol_Preview(model.Id);
            var comparentmentLisCount = service.GetJudgeComprentmetList((saved_model.SelectedLawUnitId ?? 0), saved_model.CourtId, saved_model.CaseId).Count;

            if (comparentmentLisCount > 1)
            {
                return(RedirectToAction("PreviewDoc", new { id = model.Id }));
            }
            else
            {
                var res = service.CaseSelectionProtokol_UpdateBeforeDocForSign(saved_model);
                return(RedirectToAction("SignDoc", new { id = saved_model.Id }));
            }

            //    return RedirectToAction("PreviewDoc", new { id = model.Id });
        }