public IActionResult EditManualRoles(CaseLawUnit model)
        {
            SetViewbagManualRoles(model.CaseId);

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

            string _isvalid = IsValidManualRoles(model);

            if (_isvalid != string.Empty)
            {
                ModelState.AddModelError("", _isvalid);
                return(View(nameof(EditManualRoles), model));
            }

            var currentId = model.Id;

            if (service.CaseLawUnit_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseLawUnit, model.Id, currentId == 0);
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction("CasePreview", "Case", new { id = model.CaseId }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }

            return(View(nameof(EditManualRoles), model));
        }
        private string IsValidManualRoles(CaseLawUnit model)
        {
            if (model.LawUnitId < 1)
            {
                return("Няма избран служител");
            }

            if (model.JudgeRoleId < 1)
            {
                return("Няма избрана роля");
            }

            return(string.Empty);
        }
        public IActionResult AddManualRoles(int caseId)
        {
            if (!CheckAccess(service, SourceTypeSelectVM.CaseLawUnit, null, AuditConstants.Operations.Append, caseId))
            {
                return(Redirect_Denied());
            }
            var caseCase = service.GetById <Case>(caseId);
            var model    = new CaseLawUnit()
            {
                CourtId  = caseCase.CourtId,
                CaseId   = caseCase.Id,
                DateFrom = DateTime.Now
            };

            SetViewbagManualRoles(caseId);
            return(View(nameof(EditManualRoles), model));
        }
Ejemplo n.º 4
0
        private JudgeType FillJudgeType(CaseLawUnit caseLawUnit)
        {
            JudgeType result = null;

            if (caseLawUnit != null)
            {
                (var newId, var action) = AppendUpdateIntegrationKeyAction(SourceTypeSelectVM.CaseLawUnit, caseLawUnit.Id, false);
                result = new JudgeType()
                {
                    judge_id       = newId,
                    judge_name_1   = caseLawUnit.LawUnit.FirstName,
                    judge_rename   = caseLawUnit.LawUnit.MiddleName,
                    judge_family_1 = caseLawUnit.LawUnit.FamilyName,
                    judge_family_2 = caseLawUnit.LawUnit.Family2Name,
                    judge_egn      = caseLawUnit.LawUnit.Uic
                };
            }

            return(result);
        }
        public WorkNotification NewWorkNotification(CaseLawUnit model)
        {
            string userId = GetUserIdByLawUnitId(model.LawUnitId);

            if (string.IsNullOrEmpty(userId))
            {
                return(null);
            }
            if (model.Case == null)
            {
                model.Case = repo.GetById <Case>(model.CaseId);
            }
            var info = repo.AllReadonly <CaseLawUnit>()
                       .Where(x => x.CaseId == model.CaseId && x.LawUnitId == model.LawUnitId)
                       .Where(x => x.CaseSessionId == null)
                       .Select(x => new
            {
                FullName  = x.LawUnit.FullName,
                JudgeRole = x.JudgeRole.Label,
                DateFrom  = x.DateFrom
            }).FirstOrDefault();
            var workNotification = new WorkNotification();

            workNotification.SourceType             = SourceTypeSelectVM.Case;
            workNotification.SourceId               = model.CaseId;
            workNotification.WorkNotificationTypeId = NomenclatureConstants.WorkNotificationType.NewCase;
            workNotification.Title       = $"Разпределено дело {model.Case.RegNumber}";
            workNotification.Description = $"{info.FullName}, имате разпределено дело {model.Case.RegNumber} като {info.JudgeRole}.";
            workNotification.LinkLabel   = "Дело";
            workNotification.CourtId     = model.Case.CourtId;
            workNotification.FromCourtId = userContext.CourtId;
            workNotification.FromUserId  = userContext.UserId;
            workNotification.DateCreated = info.DateFrom;
            workNotification.UserId      = userId;
            return(workNotification);
        }