Esempio n. 1
0
        public (ReportResponseItem model, Exception exception) GenerateModel()
        {
            var(data, exception) = PopulateModel();

            if (exception != null)
            {
                return(null, exception);
            }

            var model = new ReportResponseItem
            {
                ReportName        = ReportName,
                PageTitle         = ReportTitle,
                ReportDescription = ReportDescription,
                Suggestions       = data.Select(a => new SuggestionModelItem
                {
                    Name            = a.Name,
                    DrinkType       = a.Type,
                    EasyToFind      = a.EasyToFind,
                    TastingNotes    = a.TastingNotes,
                    Nose            = a.Nose,
                    Price           = a.Price,
                    AdditionalNotes = a.AdditionalNotes,
                    Aged            = a.Aged,
                    ABV             = a.ABV,
                    WorthIt         = a.WorthIt,
                    Rating          = a.Rating,
                    ActualPrice     = a.ActualPrice,
                    MaxWorthItPrice = a.MaxWorthItPrice
                }).OrderByDescending(a => a.Rating).ToList()
            };

            return(model, null);
        }
        private void ReportCreateRequest(string jsonData)
        {
            Action act = () =>
            {
                var _request = jsonData.Deserialize <ReportRequest>();

                var _response = new ReportResponse();
                _response.ReportId = _request.ReportId;
                _response.Items    = new List <ReportResponseItem>();

                var _locations = (from p in db.People
                                  join c in db.CommunicationInformations on p.Id equals c.PersonId
                                  select c.Location).Distinct().ToList();


                foreach (var _loc in _locations)
                {
                    var _respItem = new ReportResponseItem()
                    {
                        Location = _loc
                    };
                    _respItem.PersonCount = (from p in db.People
                                             join c in db.CommunicationInformations on p.Id equals c.PersonId
                                             where c.Location == _loc
                                             select p.Id).Distinct().Count();

                    _respItem.TelephoneNumberCount = (from p in db.People
                                                      join c in db.CommunicationInformations on p.Id equals c.PersonId
                                                      where c.Location == _loc
                                                      select c.TelephoneNumber).Distinct().Count();
                    _response.Items.Add(_respItem);
                }

                rabbitMQService.Publish(CommonLibrary.Constants.MessageQueue.ReportCreateResponse, _response.Serialize());
            };

            act.ExecuteCircuitPattern(throwException: false);
        }