public void SendEmails(IList <Item> items)
        {
            foreach (var item in items)
            {
                var userId     = _itemsRepository.GetUserByItemId(item.Id).Id;
                var user       = _usersRepository.Get(userId);
                var screenshot = _screenshotRepository.GetLastsByItemId(item.Id, 2);

                if (screenshot.Count >= 2)
                {
                    item.Screenshots = screenshot;
                    EmailSenderHelper.SendMessage(user, item);

                    item.UserNotified = true;
                    _itemsRepository.Update(item);
                }
            }
        }
Exemplo n.º 2
0
        public GetItemsListResponse Handle(GetItemsListRequest request) //TODO need to check for null
        {
            var response = new GetItemsListResponse();

            response.Errors = Validate(request);

            if (response.HasErrors)
            {
                return(response);
            }
            try
            {
                var items = _itemsRepository.GetByDashboardId(request.DashboardId);

                var itemsWithScreenshots = new List <Item>();

                foreach (var item in items)
                {
                    var screenshots = _screenshotRepository.GetLastsByItemId(item.Id, 15);

                    if (screenshots.Count > 0)
                    {
                        item.Screenshots = screenshots;
                    }

                    itemsWithScreenshots.Add(item);
                }

                response.Items = itemsWithScreenshots;

                return(response);
            }
            catch (Exception)
            {
                response.Errors.Add(new ErrorStatus("BAD_REQUEST"));
                return(response);
            }
        }