示例#1
0
 /// <summary>
 /// Запис на Наложени наказания към присъда
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool CasePersonSentencePunishmentCrime_SaveData(CasePersonSentencePunishmentCrime model)
 {
     try
     {
         if (model.Id > 0)
         {
             //Update
             var saved = repo.GetById <CasePersonSentencePunishmentCrime>(model.Id);
             saved.CasePersonSentencePunishmentId = model.CasePersonSentencePunishmentId;
             saved.CaseCrimeId         = model.CaseCrimeId;
             saved.PersonRoleInCrimeId = model.PersonRoleInCrimeId;
             saved.RecidiveTypeId      = model.RecidiveTypeId;
             saved.DateWrt             = DateTime.Now;
             saved.UserId = userContext.UserId;
             repo.Update(saved);
             repo.SaveChanges();
         }
         else
         {
             model.DateWrt = DateTime.Now;
             model.UserId  = userContext.UserId;
             repo.Add <CasePersonSentencePunishmentCrime>(model);
             repo.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogError(ex, $"Грешка при запис на Наложени наказания към присъда Id={ model.Id }");
         return(false);
     }
 }
示例#2
0
        public JsonResult CasePersonSentencePunishmentCrime(CasePersonSentencePunishmentCrime model)
        {
            string validationError = string.Empty;

            if (!string.IsNullOrEmpty(validationError))
            {
                return(Json(new { result = false, message = validationError }));
            }

            validationError = ValidateCasePersonSentencePunishmentCrime(model);
            if (!string.IsNullOrEmpty(validationError))
            {
                return(Json(new { result = false, message = validationError }));
            }

            var currentId = model.Id;
            var res       = service.CasePersonSentencePunishmentCrime_SaveData(model);

            if (res)
            {
                SetAuditContext(service, SourceTypeSelectVM.CasePersonSentencePunishmentCrime, model.Id, currentId == 0);
            }

            return(Json(new { result = res }));
            //return RedirectToAction(nameof(EditCasePersonSentencePunishment), new { id = model.CasePersonSentencePunishmentId });
        }
示例#3
0
        public IActionResult CasePersonSentencePunishmentCrime(int CasePersonSentencePunishmentId, int?id)
        {
            if (!CheckAccess(service, SourceTypeSelectVM.CasePersonSentencePunishmentCrime, null, AuditConstants.Operations.Append, CasePersonSentencePunishmentId))
            {
                return(Redirect_Denied());
            }

            CasePersonSentencePunishmentCrime model;

            if (id > 0)
            {
                model = nomService.GetById <CasePersonSentencePunishmentCrime>(id);
            }
            else
            {
                var casePersonSentencePunishment = service.GetById <CasePersonSentencePunishment>(CasePersonSentencePunishmentId);
                model = new CasePersonSentencePunishmentCrime()
                {
                    CaseId  = casePersonSentencePunishment.CaseId,
                    CourtId = userContext.CourtId,
                    CasePersonSentencePunishmentId = CasePersonSentencePunishmentId,
                    SentenceTypeId = casePersonSentencePunishment.SentenceTypeId
                };
            }
            SetViewbagCasePersonSentencePunishmentCrime(CasePersonSentencePunishmentId);
            return(PartialView("EditCasePersonSentencePunishmentCrimeNew", model));
        }
示例#4
0
        public IActionResult EditCasePersonSentencePunishmentCrime(CasePersonSentencePunishmentCrime model)
        {
            SetViewbagCasePersonSentencePunishmentCrime(model.CasePersonSentencePunishmentId);

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

            string _isvalid = IsValidCasePersonSentencePunishmentCrime(model);

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

            var currentId = model.Id;

            if (service.CasePersonSentencePunishmentCrime_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.CasePersonSentencePunishmentCrime, model.Id, currentId == 0);
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction(nameof(EditCasePersonSentencePunishmentCrime), new { id = model.Id }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }
            return(View(nameof(EditCasePersonSentencePunishmentCrime), model));
        }
 /// <summary>
 /// Запис на Наложени наказания към присъда
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool CasePersonSentencePunishmentCrime_SaveData(CasePersonSentencePunishmentCrime model)
 {
     try
     {
         var casePersonSentence = repo.AllReadonly <CasePersonSentencePunishment>()
                                  .Where(x => x.Id == model.CasePersonSentencePunishmentId)
                                  .Select(x => x.CasePersonSentence)
                                  .FirstOrDefault();
         var casePersonCrime = repo.AllReadonly <CasePersonCrime>()
                               .Where(x => x.CaseCrimeId == model.CaseCrimeId &&
                                      x.CaseCrimeId == casePersonSentence.CasePersonId &&
                                      x.DateExpired == null)
                               .FirstOrDefault();
         if (model.Id > 0)
         {
             //Update
             var saved = repo.All <CasePersonSentencePunishmentCrime>()
                         .Where(x => x.Id == model.Id)
                         .FirstOrDefault();
             saved.CasePersonSentencePunishmentId = model.CasePersonSentencePunishmentId;
             saved.CaseCrimeId         = model.CaseCrimeId;
             saved.PersonRoleInCrimeId = model.PersonRoleInCrimeId;
             saved.RecidiveTypeId      = model.RecidiveTypeId;
             saved.SentenceTypeId      = model.SentenceTypeId;
             saved.SentenseMoney       = model.SentenseMoney;
             saved.SentenseDays        = model.SentenseDays;
             saved.SentenseWeeks       = model.SentenseWeeks;
             saved.SentenseMonths      = model.SentenseMonths;
             saved.SentenseYears       = model.SentenseYears;
             saved.DateWrt             = DateTime.Now;
             saved.UserId = userContext.UserId;
             repo.Update(saved);
             repo.SaveChanges();
         }
         else
         {
             model.DateWrt = DateTime.Now;
             model.UserId  = userContext.UserId;
             repo.Add <CasePersonSentencePunishmentCrime>(model);
             repo.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogError(ex, $"Грешка при запис на Наложени наказания към присъда Id={ model.Id }");
         return(false);
     }
 }
示例#6
0
        /// <summary>
        /// Добавяне на Наложени наказания към присъда
        /// </summary>
        /// <param name="CasePersonSentencePunishmentId"></param>
        /// <returns></returns>
        public IActionResult AddCasePersonSentencePunishmentCrime(int CasePersonSentencePunishmentId)
        {
            if (!CheckAccess(service, SourceTypeSelectVM.CasePersonSentencePunishmentCrime, null, AuditConstants.Operations.Append, CasePersonSentencePunishmentId))
            {
                return(Redirect_Denied());
            }
            var casePersonSentencePunishment = service.GetById <CasePersonSentencePunishment>(CasePersonSentencePunishmentId);

            SetViewbagCasePersonSentencePunishmentCrime(CasePersonSentencePunishmentId);
            var model = new CasePersonSentencePunishmentCrime()
            {
                CaseId  = casePersonSentencePunishment.CaseId,
                CourtId = userContext.CourtId,
                CasePersonSentencePunishmentId = CasePersonSentencePunishmentId,
            };

            return(View(nameof(EditCasePersonSentencePunishmentCrime), model));
        }
示例#7
0
        private string ValidateCasePersonSentencePunishmentCrime(CasePersonSentencePunishmentCrime model)
        {
            if (model.CaseCrimeId < 1)
            {
                return("Изберете престъпление.");
            }

            if (model.PersonRoleInCrimeId < 1)
            {
                return("Изберете роля на лицето в престъплението.");
            }

            if (model.RecidiveTypeId < 1)
            {
                return("Изберете рецидив.");
            }

            return(string.Empty);
        }
示例#8
0
        /// <summary>
        /// Валидация преди запис на Наложени наказания към присъда
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private string IsValidCasePersonSentencePunishmentCrime(CasePersonSentencePunishmentCrime model)
        {
            if (model.CaseCrimeId < 1)
            {
                return("Изберете престъпление");
            }

            if (model.PersonRoleInCrimeId < 1)
            {
                return("Изберете роля");
            }

            if (model.RecidiveTypeId < 1)
            {
                return("Изберете рецидив");
            }

            return(string.Empty);
        }