示例#1
0
        public IEnumerable <object> GetInquiriesListForUser(string hostPort, int vkId)
        {
            var user = _userService.GetUserByVkId(vkId);

            if (user == null)
            {
                return(null);
            }

            var inquiries        = _inquiryRepository.GetListForUser(user);
            var inquiriesForUser = new List <InqueriesForUserModel>();

            foreach (var inquiry in inquiries)
            {
                bool uploaded = inquiry.Purchase != null;

                inquiriesForUser.Add(new InqueriesForUserModel()
                {
                    ApplicationId            = inquiry.Id,
                    ApplicationUserFirstName = inquiry.User?.FirstName,
                    ApplicationUserLastName  = inquiry.User?.LastName,
                    Price         = inquiry.Offering.Price.ToString(CultureInfo.InvariantCulture),
                    OfferingPhoto = Path.Combine("http://", hostPort + @"/" + inquiry.Offering?.OfferingPhoto?.ImagePath),
                    Uploaded      = uploaded,
                    Text          = inquiry.Text,
                    AvatarPath    = inquiry.User?.AvatarPath,
                    Title         = inquiry.Offering?.Title
                });
            }
            inquiriesForUser.Reverse();

            return(inquiriesForUser);
        }