Exemple #1
0
        /// <summary>
        /// Обединяване на дела
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UnionCase(CaseMigrationUnionVM model)
        {
            try
            {
                var lastInitialCaseId = repo.AllReadonly <CaseMigration>()
                                        .Where(x => x.CaseId == model.CaseId)
                                        .OrderBy(x => x.Id)
                                        .Select(x => x.InitialCaseId)
                                        .DefaultIfEmpty(model.CaseId)
                                        .FirstOrDefault();

                var newCase = repo.GetById <Case>(model.CaseId);
                var oldCase = repo.GetById <Case>(model.CaseToUnionId);

                newCase.LoadIndex = Math.Max(newCase.LoadIndex, oldCase.LoadIndex);

                var newCaseMigration = new CaseMigration()
                {
                    InitialCaseId       = lastInitialCaseId,
                    CaseId              = model.CaseId,
                    CourtId             = newCase.CourtId,
                    PriorCaseId         = model.CaseToUnionId,
                    CaseMigrationTypeId = NomenclatureConstants.CaseMigrationTypes.CaseUnion,
                    DateWrt             = DateTime.Now,
                    UserId              = userContext.UserId,
                    SendToTypeId        = NomenclatureConstants.CaseMigrationSendTo.Court,
                    SendToCourtId       = userContext.CourtId,
                    Description         = model.Description
                };
                var oldCaseMigration = new CaseMigration()
                {
                    InitialCaseId       = lastInitialCaseId,
                    CaseId              = model.CaseToUnionId,
                    CourtId             = oldCase.CourtId,
                    PriorCaseId         = model.CaseId,
                    CaseMigrationTypeId = NomenclatureConstants.CaseMigrationTypes.CaseUnion,
                    DateWrt             = DateTime.Now,
                    UserId              = userContext.UserId,
                    SendToTypeId        = NomenclatureConstants.CaseMigrationSendTo.Court,
                    SendToCourtId       = userContext.CourtId
                };

                repo.Add(newCaseMigration);
                repo.Add(oldCaseMigration);
                repo.Update(newCase);

                repo.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"UnionCase CaseId={model.CaseId}; UnionCaseId={model.CaseToUnionId}");
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Обединяване на дело
        /// </summary>
        /// <param name="caseId"></param>
        /// <returns></returns>
        public IActionResult UnionCase(int caseId)
        {
            var caseInfo = caseService.Case_GetById(caseId);
            var model    = new CaseMigrationUnionVM()
            {
                CaseId = caseId
            };

            model.CaseInfo = $"{caseInfo.RegNumber} ({caseInfo.CaseTypeCode})";
            SetViewBag(model);
            return(View(model));
        }
Exemple #3
0
 public IActionResult UnionCase(CaseMigrationUnionVM model)
 {
     if (model.CaseToUnionId == 0)
     {
         ModelState.AddModelError(nameof(CaseMigrationUnionVM.CaseToUnionId), "Дело, което ще се обедини с текущото");
     }
     if (!ModelState.IsValid)
     {
         SetViewBag(model);
         return(View(model));
     }
     if (migService.UnionCase(model))
     {
         SetSuccessMessage(MessageConstant.Values.SaveOK);
     }
     else
     {
         SetErrorMessage("Проблем при приемане на движение на дело.");
     }
     return(RedirectToAction(nameof(Index), new { caseId = model.CaseId }));
 }
Exemple #4
0
 void SetViewBag(CaseMigrationUnionVM model)
 {
     ViewBag.caseId      = model.CaseId;
     ViewBag.breadcrumbs = commonService.Breadcrumbs_GetForCase(model.CaseId);
     SetHelpFile(HelpFileValues.CaseMigration);
 }