private List <OfferingPostModel> CreateOfferingPostModels(List <Offering> offerings, string hostPort, bool isOriginal = false) { var offeringModels = new List <OfferingPostModel>(); foreach (var offering in offerings) { string path = offering.User.AvatarPath; if (string.IsNullOrEmpty(path)) { path = Path.Combine("http://", hostPort + @"/" + "Content/Avatars/size50/camera_50.png"); } var offeringPostModel = new OfferingPostModel(); offeringPostModel.OfferingId = offering.Id; offeringPostModel.FirstName = offering.User.FirstName; offeringPostModel.LastName = offering.User.LastName; offeringPostModel.ImagePath = isOriginal ? Path.Combine("http://", hostPort + @"/" + offering.OfferingPhoto.ImagePath) : Path.Combine("http://", hostPort + @"/" + offering.OfferingPhoto.ImageWithWaterMarkPath); offeringPostModel.Title = offering.Title; offeringPostModel.Price = offering.Price.ToString(CultureInfo.InvariantCulture); offeringPostModel.DateCreated = offering.DateCreated; offeringPostModel.AvatarPath = path; offeringPostModel.Description = offering.Desctiption; offeringPostModel.CategotyName = offering.OfferingCategory != null ? offering.OfferingCategory.Name : "NoCategory"; offeringModels.Add(offeringPostModel); } return(offeringModels); }
private List <OfferingPostModel> CreateOfferingPostModelsRevers(List <Offering> offerings, string hostPort, int vkId) { var offeringModels = new List <OfferingPostModel>(); var userId = _userService.GetUserByVkId(vkId).Id; foreach (var offering in offerings) { string path = offering.User.AvatarPath; if (string.IsNullOrEmpty(path)) { path = Path.Combine("http://", hostPort + @"/" + "Content/Avatars/size50/camera_50.png"); } var imagePath = offering.OfferingPhoto.ImageWithWaterMarkPath == null?Path.Combine("http://", hostPort + @"/" + offering.OfferingPhoto.ImagePath) : Path.Combine("http://", hostPort + @"/" + offering.OfferingPhoto.ImageWithWaterMarkPath); var item = new OfferingPostModel(); item.OfferingId = offering.Id; item.FirstName = offering.User.FirstName; item.LastName = offering.User.LastName; item.ImagePath = imagePath; item.Title = offering.Title; item.Price = offering.Price.ToString(CultureInfo.InvariantCulture); item.DateCreated = offering.DateCreated; item.AvatarPath = path; item.Description = offering.Desctiption; item.CategoryId = offering.OfferingCategoryId ?? 0; item.CategotyName = offering.OfferingCategory != null ? offering.OfferingCategory.Name : "NoCategory"; var offeringType = (OfferingType)offering.OfferingTypeId; switch (offeringType) { case OfferingType.Selfie: item.Checked = _inquiryService.IsExistInquiryOnOffering(vkId, offering.Id); break; case OfferingType.Sale: item.Checked = offering.UserBuyOfferings.FirstOrDefault(x => x.UserId == userId) != null; break; default: break; } offeringModels.Add(item); } offeringModels.Reverse(); return(offeringModels); }
public OfferingPostModel GetOfferingByFilePath(string path, string hostPort) { var offering = _offeringRepository.GetByPhotoPath(path); var model = new OfferingPostModel() { OfferingId = offering.Id, FirstName = offering.User.FirstName, LastName = offering.User.LastName, ImagePath = Path.Combine("http://", hostPort + @"/" + offering.OfferingPhoto.ImagePath), Title = offering.Title, Price = offering.Price.ToString(CultureInfo.InvariantCulture), DateCreated = offering.DateCreated, AvatarPath = offering.User.AvatarPath, Description = offering.Desctiption, Checked = false }; return(model); }