Ejemplo n.º 1
0
        public IActionResult EditMeetingUser(CaseSessionMeetingUser model)
        {
            SetViewbagMeetengUser(model.CaseSessionMeetingId);
            if (!ModelState.IsValid)
            {
                return(View(nameof(EditMeetingUser), model));
            }

            string _isvalid = IsValidMeetingUser(model);

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

            var currentId = model.Id;

            if (service.CaseSessionMeetingUser_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseSessionMeetingUser, model.Id, currentId == 0);
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction(nameof(EditMeetingUser), new { id = model.Id }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }
            return(View(nameof(EditMeetingUser), model));
        }
        /// <summary>
        /// Запис на секретари към Тайни съвещания/сесии към заседание
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool CaseSessionMeetingUser_SaveData(CaseSessionMeetingUser model)
        {
            try
            {
                if (model.Id > 0)
                {
                    //Update
                    var saved = repo.GetById <CaseSessionMeetingUser>(model.Id);
                    saved.SecretaryUserId = model.SecretaryUserId;
                    saved.DateWrt         = DateTime.Now;
                    saved.UserId          = userContext.UserId;
                    caseDeadlineService.DeadLineOpenSessionResult(saved);
                    repo.Update(saved);
                }
                else
                {
                    //Insert
                    model.DateWrt = DateTime.Now;
                    model.UserId  = userContext.UserId;
                    caseDeadlineService.DeadLineOpenSessionResult(model);
                    repo.Add <CaseSessionMeetingUser>(model);
                }

                repo.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Грешка при запис на секретари към сесии на заседание Id={ model.Id }");
                return(false);
            }
        }
Ejemplo n.º 3
0
        private string IsValidMeetingUser(CaseSessionMeetingUser model)
        {
            if ((model.SecretaryUserId ?? string.Empty) == string.Empty)
            {
                return("Няма избран юзер");
            }

            return(string.Empty);
        }
Ejemplo n.º 4
0
        public IActionResult AddMeetingUser(int caseSessionMeetingId)
        {
            if (!CheckAccess(service, SourceTypeSelectVM.CaseSessionMeetingUser, null, AuditConstants.Operations.Append, caseSessionMeetingId))
            {
                return(Redirect_Denied());
            }
            var meeting = service.GetById <CaseSessionMeeting>(caseSessionMeetingId);
            var model   = new CaseSessionMeetingUser()
            {
                CaseId  = meeting.CaseId,
                CourtId = meeting.CourtId,
                CaseSessionMeetingId = caseSessionMeetingId
            };

            SetViewbagMeetengUser(caseSessionMeetingId);
            return(View(nameof(EditMeetingUser), model));
        }
Ejemplo n.º 5
0
        public void DeadLineOpenSessionResult(CaseSessionMeetingUser user)
        {
            var meeting = repo.AllReadonly <CaseSessionMeeting>()
                          .Where(x => x.Id == user.CaseSessionMeetingId)
                          .FirstOrDefault();

            if (meeting == null)
            {
                return;
            }
            var session = repo.AllReadonly <CaseSession>()
                          .Where(x => x.Id == meeting.CaseSessionId)
                          .FirstOrDefault();

            if (session == null)
            {
                return;
            }
            var oldDeadLine = repo.AllReadonly <CaseDeadline>()
                              .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession &&
                                     x.SourceId == session.Id &&
                                     x.DeadlineTypeId == NomenclatureConstants.DeadlineType.OpenSessionResult)
                              .FirstOrDefault();

            if (oldDeadLine != null && oldDeadLine.Id > 0)
            {
                var workNotifications = workNotificationService.NewWorkNotificationSecretary(oldDeadLine);
                foreach (var notification in workNotifications)
                {
                    notification.CaseDeadlineId = oldDeadLine.Id;
                    if (notification.Id == 0)
                    {
                        repo.Add(notification);
                    }
                    else
                    {
                        repo.Update(notification);
                    }
                }
            }
        }
        /// <summary>
        /// Запис на Тайни съвещания/сесии към заседание
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool CaseSessionMeeting_SaveData(CaseSessionMeetingEditVM model)
        {
            try
            {
                model.CourtHallId = model.CourtHallId.EmptyToNull();
                var modelSave = FillCaseSessionMeeting(model);
                using (TransactionScope ts = new TransactionScope())
                {
                    if (model.Id > 0)
                    {
                        //Update
                        var saved = repo.GetById <CaseSessionMeeting>(modelSave.Id);
                        saved.SessionMeetingTypeId = modelSave.SessionMeetingTypeId;
                        saved.CourtHallId          = model.CourtHallId;
                        saved.DateFrom             = modelSave.DateFrom;
                        saved.DateTo      = modelSave.DateTo;
                        saved.Description = modelSave.Description;
                        saved.DateWrt     = DateTime.Now;
                        saved.UserId      = userContext.UserId;
                        repo.Update(saved);

                        var caseSessionMeetingUsers = repo.AllReadonly <CaseSessionMeetingUser>()
                                                      .Where(x => x.CaseSessionMeetingId == modelSave.Id)
                                                      .ToList();
                        repo.DeleteRange <CaseSessionMeetingUser>(caseSessionMeetingUsers);
                    }
                    else
                    {
                        //Insert
                        modelSave.DateWrt = DateTime.Now;
                        modelSave.UserId  = userContext.UserId;
                        repo.Add <CaseSessionMeeting>(modelSave);
                    }

                    if (model.CaseSessionMeetingUser != null)
                    {
                        foreach (var checkedItem in model.CaseSessionMeetingUser.Where(x => x.Checked))
                        {
                            var userSave = new CaseSessionMeetingUser()
                            {
                                CourtId = modelSave.CourtId,
                                CaseId  = modelSave.CaseId,
                                CaseSessionMeetingId = modelSave.Id,
                                SecretaryUserId      = checkedItem.Value,
                                DateWrt = DateTime.Now,
                                UserId  = userContext.UserId
                            };

                            repo.Add(userSave);
                        }
                    }

                    if (model.IsAutoCreate ?? false)
                    {
                        if (model.SessionStateId != null)
                        {
                            var caseSessionUpdate = repo.GetById <CaseSession>(model.CaseSessionId);
                            caseSessionUpdate.SessionStateId = model.SessionStateId ?? 0;
                            caseSessionUpdate.DateWrt        = DateTime.Now;
                            caseSessionUpdate.UserId         = userContext.UserId;
                            repo.Update(caseSessionUpdate);
                        }
                    }

                    repo.SaveChanges();

                    //Запис на пари за заседатели
                    var caseSession = repo.AllReadonly <CaseSession>()
                                      .Where(x => x.Id == model.CaseSessionId)
                                      .FirstOrDefault();
                    (bool result, string errorMessage) = moneyService.CalcEarningsJury(caseSession, userContext.CourtId);
                    if (result == false)
                    {
                        return(false);
                    }

                    if (model.Id < 1)
                    {
                        model.Id = modelSave.Id;
                    }

                    ts.Complete();
                }

                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Грешка при запис на тайно съвещание Id={ model.Id }");
                return(false);
            }
        }