public List <OfferingPostModel> GetWithSerach(OfferingType offeringType, int vkId, string hostPort, string search, int CategoryId = 0) { var offerings = _offeringRepository.GetListWithSerach(offeringType, search, CategoryId);//.Where(o => o.User.VkId != vkId).ToList(); var offeringModels = CreateOfferingPostModelsRevers(offerings, hostPort, vkId); return(offeringModels); }
public List <OfferingPostModel> GetUserOfferings(string hostPort, int vkId, OfferingType offeringType) { var offerings = _offeringRepository.GetListWithUsersAndPhotos(offeringType).Where(o => o.User.VkId == vkId).ToList(); var offeringModels = CreateOfferingPostModelsRevers(offerings, hostPort, vkId); return(offeringModels); }
//TODO: This crap should be rewrite! public List <Offering> GetRangeList(int startPosition, int count, int vkId, OfferingType offeringType) { var offeringTypeId = (int)offeringType; if (count <= 0) { throw new ArgumentException("param count can not be <= 0"); } var offeringsCount = _db.Offerings.Count(o => o.Closed == false && o.User.VkId != vkId && o.OfferingTypeId == offeringTypeId); if (offeringsCount < startPosition + count) { if (offeringsCount > startPosition && offeringsCount < count) { return(_db.Offerings .Include(o => o.User) .Include(o => o.OfferingPhoto).Include(o => o.OfferingCategory) .Where(o => o.Closed == false && o.User.VkId != vkId && o.OfferingTypeId == offeringTypeId) .OrderByDescending(o => o.Id).Skip(startPosition).Take(offeringsCount - startPosition - 1) .ToList()); } if (offeringsCount <= startPosition) { return(new List <Offering>()); } if (offeringsCount < count) { return(new List <Offering>()); } return(_db.Offerings .Include(o => o.User) .Include(o => o.OfferingPhoto).Include(o => o.OfferingCategory) .Where(o => o.Closed == false && o.User.VkId != vkId && o.OfferingTypeId == offeringTypeId) .OrderByDescending(o => o.Id).Skip(startPosition).Take(offeringsCount - startPosition) .ToList()); } return(_db.Offerings .Include(o => o.User) .Include(o => o.OfferingPhoto).Include(o => o.OfferingCategory) .Where(o => o.Closed == false && o.User.VkId != vkId && o.OfferingTypeId == offeringTypeId) .OrderByDescending(o => o.Id).Skip(startPosition).Take(count) .ToList()); }
public List <Offering> GetListWithUsersAndPhotosByUserVkId(int vkid, OfferingType offeringType) { var offeringTypeId = (int)offeringType; return(_db.Offerings .Include(o => o.User) .Include(o => o.OfferingPhoto) .Include(o => o.OfferingCategory) .Where(o => o.User.VkId == vkid && o.Closed == false && o.OfferingTypeId == offeringTypeId) .ToList()); }
public List <Offering> GetListWithUsersAndPhotos(OfferingType offeringType) { var offeringTypeId = (int)offeringType; return(_db.Offerings .Include(o => o.User) .Include(o => o.OfferingPhoto) .Include(o => o.OfferingCategory) .Where(i => i.Closed == false && i.OfferingTypeId == offeringTypeId) .ToList()); }
public List <Offering> GetListWithSerach(OfferingType offeringType, string search, int CategoryId = 0) { var searchStr = search.Trim().ToLower(); var offeringTypeId = (int)offeringType; return(_db.Offerings.Include(o => o.OfferingCategory) .Include(o => o.User) .Include(o => o.OfferingPhoto) .Include(o => o.OfferingCategory) .Where( o => (o.Closed == false && o.OfferingTypeId == offeringTypeId) && (CategoryId == 0 || o.OfferingCategoryId == CategoryId) && (searchStr == null || searchStr == "" || o.Title.ToLower().Contains(searchStr)) ) .ToList()); }
public List <OfferingPostModel> Get(string hostPort, int vkId, int startposition, int count, OfferingType offeringType) { var offerings = _offeringRepository.GetRangeList(startposition, count, vkId, offeringType) .Where(o => o.User.VkId != vkId).ToList(); var offeringModels = CreateOfferingPostModels(offerings, hostPort, vkId); return(offeringModels); }
public void Create(string originalFilePath, string wmFilePath, int vkId, decimal price, string description, string title, int categoryId, OfferingType offeringType) { var offeringTypeId = (int)offeringType; var offering = new Offering(); var photo = new OfferingPhoto(); photo.ImagePath = originalFilePath; photo.ImageWithWaterMarkPath = wmFilePath; offering.UserId = _userService.GetUserByVkId(vkId).Id; offering.OfferingPhoto = photo; offering.Price = price; offering.Desctiption = description; offering.Title = title; offering.DateCreated = DateTime.UtcNow; offering.OfferingTypeId = offeringTypeId; if (categoryId != 0) { offering.OfferingCategoryId = categoryId; } _offeringRepository.Create(offering); }
public List <Offering> GetList(OfferingType offeringType) { var offeringTypeId = (int)offeringType; return(_db.Offerings.Include(o => o.OfferingCategory).Where(o => o.Closed == false && o.OfferingTypeId == offeringTypeId).ToList()); }