Ejemplo n.º 1
0
        public GetHospitalNoticesPageInformationCommandAnswer GetHospitalNoticesPageInformation(
            GetHospitalNoticesPageInformationCommand 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)
                .Take(100)
                .Select(model => new MessageTableItem
                {
                    SendDate = model.Date,
                    AuthorName = model.UserFrom.Name,
                    Title = model.Title,
                    IsRead = model.IsRead,
                    MessageId = model.Id
                });

            return new GetHospitalNoticesPageInformationCommandAnswer
            {
                Token = (Guid) command.Token,
                Messages = results.ToList(),
                OlnyUnRead = command.OlnyUnRead,
                OnlyToday = command.OnlyToday
            };
        }
 public ActionResult Index(GetHospitalNoticesPageInformationCommand command)
 {
     var answer = _noticesService.GetHospitalNoticesPageInformation(command);
     return View(answer);
 }