예제 #1
0
        public bool Counter_GetNotificationCounter(CaseNotification model, int courtId)
        {
            try
            {
                var counterId = repo.AllReadonly <Counter>()
                                .Where(x => x.CourtId == courtId && x.CounterTypeId == NomenclatureConstants.CounterTypes.Notification)
                                .Select(x => x.Id)
                                .FirstOrDefault();
                if (counterId > 0)
                {
                    var courtCode = repo.AllReadonly <Court>().FirstOrDefault(x => x.Id == courtId)?.Code;


                    model.RegNumber = $"{DateTime.Now.Year}{courtCode}{Counter_GetValue(counterId)}";
                    model.RegDate   = DateTime.Now;
                    return(true);
                }
                else
                {
                    throw new Exception($"Няма настроен брояч за известия. Court={courtId}");
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Грешка при запис на брояч за известия. Court={courtId}");
            }
            return(false);
        }
예제 #2
0
        // GET: /Cases/
        public ActionResult Index(int?Sort = 0)
        {
            String      UserID = User.Identity.GetUserId();
            List <Case> cases  = new List <Case>();

            if (Sort == 1)
            {
                cases = db.Cases.Where(p => string.Compare(p.SolicitorID, UserID) == 0 || string.Compare(p.ClientID, UserID) == 0).OrderBy(p => p.CaseName).ToList();
            }
            else if (Sort == 2)
            {
                cases = db.Cases.Where(p => string.Compare(p.SolicitorID, UserID) == 0 || string.Compare(p.ClientID, UserID) == 0).OrderBy(p => p.CreateDateTime).ToList();
            }
            else
            {
                cases = db.Cases.Where(p => string.Compare(p.SolicitorID, UserID) == 0 || string.Compare(p.ClientID, UserID) == 0).ToList();
            }

            //encapsulate case into CaseNotification model

            List <CaseNotification> models = new List <CaseNotification>();

            foreach (Case c in cases)
            {
                CaseNotification model = new CaseNotification();
                model.Case = c;
                model.NotificationNumber = db.Notification.Where(p => p.ReceiverID == UserID && p.CaseID == c.CaseID && !p.Checked).ToList().Count();
                models.Add(model);
            }
            ViewBag.UserID = UserID;
            return(View(models));
        }
        private WorkNotification NewWorkNotificationDeliveredList(CaseNotification caseNotification)
        {
            var userId = GetJudgeUserId(caseNotification.CaseId);

            if (userId == null)
            {
                return(null);
            }
            var workNotification = repo.AllReadonly <WorkNotification>()
                                   .Where(x => x.SourceType == SourceTypeSelectVM.CaseSession)
                                   .Where(x => x.SourceId == caseNotification.CaseSessionId)
                                   .Where(x => x.WorkNotificationTypeId == NomenclatureConstants.WorkNotificationType.ListDelivered)
                                   .FirstOrDefault();

            if (workNotification != null)
            {
                return(null);
            }

            var aCase       = GetCaseByNotification(caseNotification);
            var caseSession = repo.AllReadonly <CaseSession>()
                              .Where(x => x.Id == caseNotification.CaseSessionId)
                              .FirstOrDefault();

            var personList = repo.AllReadonly <CaseSessionNotificationList>()
                             .Where(x => x.CaseSessionId == caseNotification.CaseSessionId && x.DateExpired == null)
                             .ToList();
            var delivered     = NotificationDelivered();
            var notifications = repo.AllReadonly <CaseNotification>()
                                .Where(x => delivered.Contains(x.NotificationStateId))
                                .Where(x => x.CaseSessionId == caseNotification.CaseSessionId)
                                .ToList();

            if (personList.Any(x => x.CasePersonId != null && !notifications.Any(n => n.CasePersonId == x.CasePersonId)))
            {
                return(null);
            }
            if (personList.Any(x => x.CaseLawUnitId != null && !notifications.Any(n => n.CaseLawUnitId == x.CaseLawUnitId)))
            {
                return(null);
            }
            var model = new WorkNotification();

            model.SourceType             = SourceTypeSelectVM.CaseSession;
            model.SourceId               = caseNotification.CaseSessionId ?? 0;
            model.WorkNotificationTypeId = NomenclatureConstants.WorkNotificationType.ListDelivered;
            model.Title       = $"Известията от списъка за сесия от {caseSession.DateFrom.ToString(FormattingConstant.NormalDateFormat)}  са доставени";
            model.Description = $"Известията по дело: {aCase.RegNumber}/{aCase.RegDate.ToString(FormattingConstant.NormalDateFormat)} за сесията от {caseSession.DateFrom.ToString(FormattingConstant.NormalDateFormat)} " +
                                " са доставени";
            model.LinkLabel   = "Списък за " + caseSession.DateFrom.ToString(FormattingConstant.NormalDateFormat);
            model.CourtId     = aCase.CourtId;
            model.FromCourtId = userContext.CourtId;
            model.FromUserId  = userContext.UserId;
            model.DateCreated = DateTime.Now;
            model.UserId      = userId;
            return(model);
        }
        private Case GetCaseByNotification(CaseNotification caseNotification)
        {
            var aCase = caseNotification.Case;

            if (aCase == null)
            {
                aCase = repo.AllReadonly <Case>()
                        .Where(x => x.Id == caseNotification.CaseId)
                        .FirstOrDefault();
            }
            return(aCase);
        }
        public WorkNotification NewWorkNotification(CaseNotification caseNotification)
        {
            if (caseNotification.NotificationStateId == NomenclatureConstants.NotificationState.UnDelivered)
            {
                return(NewWorkNotificationUnDelivered(caseNotification));
            }

            if (caseNotification.CaseSessionId > 0 && caseNotification.CaseSessionActId == null && caseNotification.NotificationStateId != NomenclatureConstants.NotificationState.UnDelivered)
            {
                return(NewWorkNotificationDeliveredList(caseNotification));
            }

            return(null);
        }
        private WorkNotification NewWorkNotificationUnDelivered(CaseNotification caseNotification)
        {
            var userId = GetJudgeUserId(caseNotification.CaseId);

            if (userId == null)
            {
                return(null);
            }
            var workNotification = repo.AllReadonly <WorkNotification>()
                                   .Where(x => x.SourceType == SourceTypeSelectVM.CaseNotification)
                                   .Where(x => x.SourceId == caseNotification.Id)
                                   .Where(x => x.WorkNotificationTypeId == NomenclatureConstants.WorkNotificationType.UnDeliveredNotification)
                                   .FirstOrDefault();

            if (workNotification != null)
            {
                return(null);
            }

            var aCase            = GetCaseByNotification(caseNotification);
            var notificationType = caseNotification.NotificationType;

            if (notificationType == null)
            {
                notificationType = repo.AllReadonly <NotificationType>()
                                   .Where(x => x.Id == (caseNotification.NotificationTypeId ?? 0))
                                   .FirstOrDefault();
            }

            var model = new WorkNotification();

            model.SourceType             = SourceTypeSelectVM.CaseNotification;
            model.SourceId               = caseNotification.Id;
            model.WorkNotificationTypeId = NomenclatureConstants.WorkNotificationType.UnDeliveredNotification;
            model.Title       = $"Върнато известие {caseNotification.RegNumber} ";
            model.Description = $"{notificationType.Label}  {caseNotification.RegNumber}/{caseNotification.RegDate.ToString(FormattingConstant.NormalDateFormat)}" +
                                " е върнато в цялост";
            model.LinkLabel   = notificationType.Label;
            model.CourtId     = aCase.CourtId;
            model.FromCourtId = userContext.CourtId;
            model.FromUserId  = userContext.UserId;
            model.DateCreated = DateTime.Now;
            model.UserId      = userId;
            return(model);
        }
예제 #7
0
 public bool Counter_GetNotificationCounter(CaseNotification model, int courtId)
 {
     throw new NotImplementedException();
 }