public ActionResult Index(GetClinicNoticesPageInformationCommand command)
 {
     var answer = _noticesService.GetClinicNoticesPageInformation(command);
     return View(answer);
 }
Пример #2
0
        public GetClinicNoticesPageInformationCommandAnswer GetClinicNoticesPageInformation(
            GetClinicNoticesPageInformationCommand command)
        {
            var user = _tokenManager.GetUserByToken(command.Token);

            var today = DateTime.Now.Date;

            var results = ((IDbSet<MessageStorageModel>)_messageRepository.GetModels())
                .Include(model => model.UserFrom)
                .Where(model => model.UserToId == user.Id)
                .Where(model => model.ShowStatus == TwoSideShowStatus.ToSideOnly || model.ShowStatus == TwoSideShowStatus.Showed)
                .Where(model => command.OlnyUnRead != true || !model.IsRead)
                .Where(model => command.OnlyToday != true || model.Date == today)
                .Select(model => new MessageTableItem
                {
                    SendDate = model.Date,
                    AuthorName = model.UserFrom.Name,
                    Title = model.Title,
                    IsRead = model.IsRead,
                    MessageId = model.Id
                }).ToList();

            return new GetClinicNoticesPageInformationCommandAnswer
            {
                Token = (Guid) command.Token,
                Messages = results.ToList(),
                OlnyUnRead = command.OlnyUnRead,
                OnlyToday = command.OnlyToday
            };
        }