public List <ProductAppIG4Item> GetBestBuy(double Latitude, double Longitude, int met, int page, int pagesize) { var date = DateTime.Now.TotalSeconds(); var query = from c in FDIDB.Shop_Product where c.IsShow == true && c.IsDelete == false && c.HasTransfer == true && ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) / 1000 < met select new ProductAppIG4Item { ID = c.ID, Name = c.Name, PriceNew = c.PriceNew, Ratings = c.Ratings ?? 0, AvgRating = c.AvgRating ?? 0, UrlPicture = c.Gallery_Picture.Folder + c.Gallery_Picture.Url, Latitude = c.Latitude, HasTransfer = c.HasTransfer, Longitude = c.Longitude, QuantityOut = c.QuantityOut, Sort = !c.CustomerID1.HasValue ? (c.Customer.Order_Package.Where(m => m.DateStart <date && m.DateEnd> date).Select(m => m.Customer_Type.Sort).FirstOrDefault() ?? 10000) : 0, Km = ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) / 1000 }; query = query.OrderBy(m => m.Sort).OrderBy(m => m.Km).ThenByDescending(m => m.QuantityOut); query = query.Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }
public List <ProductAppIG4Item> GetMyProduct(int customerId, int categoryId, string name, int maxKm, int minPrice, int maxPrice, double Latitude, double Longitude, int page, int pagesize) { var query = from c in FDIDB.Shop_Product where (c.CategoryId == categoryId || categoryId == 0) && c.IsShow == true && c.IsDelete == false && (c.CustomerID == customerId || c.CustomerID1 == customerId) && c.Name.Contains(name) && (minPrice == 0 || c.PriceNew >= minPrice) && (maxPrice == 0 || c.PriceNew <= maxPrice) && (maxKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) <= maxKm) orderby c.ID descending select new ProductAppIG4Item() { ID = c.ID, Name = c.Name, PriceNew = c.PriceNew, SizeItem = c.SizeID != null ? new ProductSizeItem { ID = c.Product_Size.ID, Name = c.Product_Size.Name, Value = c.Product_Size.Value } : null, Ratings = c.Ratings ?? 0, AvgRating = c.AvgRating ?? 0, UrlPicture = c.Gallery_Picture.Folder + c.Gallery_Picture.Url, Latitude = c.Latitude, Longitude = c.Longitude, QuantityOut = c.QuantityOut ?? 0, Quantity = c.Quantity, HasTransfer = c.HasTransfer != null && c.HasTransfer.Value }; query = query.Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }
public List <ProductAppIG4Item> GetIsReviewItemByCategoryId(int id, string name, double minKm, double maxKm, int minPrice, int maxPrice, double Latitude, double Longitude, int page, int pagesize) { var date = DateTime.Now.TotalSeconds(); var query = from c in FDIDB.Shop_Product where c.CategoryId == id && c.IsShow == true && c.IsDelete == false && c.IsUpcoming == true && (maxKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) <= maxKm) && (minKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) >= minKm) && (maxPrice == 0 || c.PriceNew <= maxPrice) && (minPrice == 0 || c.PriceNew >= minPrice) && c.Name.Contains(name) select new ProductAppIG4Item { ID = c.ID, Name = c.Name, PriceNew = c.PriceNew, Ratings = c.Ratings ?? 0, AvgRating = c.AvgRating ?? 0, UrlPicture = c.Gallery_Picture.Folder + c.Gallery_Picture.Url, Latitude = c.Latitude, Longitude = c.Longitude, HasTransfer = c.HasTransfer, Sort = !c.CustomerID1.HasValue ? (c.Customer.Order_Package.Where(m => m.DateStart <date && m.DateEnd> date).Select(m => m.Customer_Type.Sort).FirstOrDefault() ?? 10000) : 0, }; query = query.OrderBy(m => m.Sort).OrderByDescending(m => m.AvgRating).ThenByDescending(m => m.Ratings); query = query.Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }
public ProductAppIG4Item GetProductItem(int id, double Latitude = 0, double Longitude = 0) { var date = DateTime.Now.TotalSeconds(); var query = from c in FDIDB.Shop_Product where c.IsDelete == false && c.ID == id select new ProductAppIG4Item { ID = c.ID, Name = c.Name, CategoryName = c.Category.Name, UrlPicture = c.Gallery_Picture.Folder + c.Gallery_Picture.Url, PriceNew = c.PriceNew, CateId = c.CategoryId, LstPictures = c.Shop_Product_Picture.Select(m => new PictureAppIG4Item { ID = m.Gallery_Picture.ID, Folder = m.Gallery_Picture.Folder, Url = m.Gallery_Picture.Url }), Description = c.Description, CustomerId = c.CustomerID, CustomerId1 = c.CustomerID1, Quantity = c.Quantity, QuantityOut = c.QuantityOut, Type = c.Type, HasTransfer = c.HasTransfer, Ratings = c.Ratings ?? 0, AvgRating = c.AvgRating ?? 0, IsPrestige = c.CustomerID1.HasValue, CustomerItem = new Customer1Item { Fullname = c.Customer.FullName, Mobile = c.Customer.Mobile, IsPrestige = c.Customer.IsPrestige, TypePoint = c.Customer.IsPrestige ? 10000 : c.Customer.Order_Package.Where(a => a.DateStart >= date && a.DateEnd < date).Select(a => a.Customer_Type.Type).FirstOrDefault(), CustomerAddressItem = c.Customer.CustomerAddresses.Where(m => m.IsDefault).Select(m => new CustomerAddressAppIG4Item { Address = m.Address, Longitude = m.Longitude, Latitude = m.Latitude, Km = ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)m.Latitude, (float)m.Longitude) }).FirstOrDefault() }, CustomerItem1 = new Customer2Item { Fullname = c.Customer.FullName, Mobile = c.Customer.Mobile, IsPrestige = true, CustomerAddressItem = c.Customer.CustomerAddresses.Where(m => m.IsDefault).Select(m => new CustomerAddressAppIG4Item { Address = m.Address, Longitude = m.Longitude, Latitude = m.Latitude, Km = ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)m.Latitude, (float)m.Longitude) }).FirstOrDefault() } }; return(query.FirstOrDefault()); }
public async Task <int> ProductsIsReview(int categoryId, string name, double minKm, double maxKm, int minPrice, int maxPrice, double Latitude, double Longitude) { var query = FDIDB.Shop_Product.Where(m => m.CategoryId == categoryId && m.IsDelete == false && m.IsUpcoming == true && (maxKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)m.Latitude, (float)m.Longitude) <= maxKm) && (minKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)m.Latitude, (float)m.Longitude) >= minKm) && (maxPrice == 0 || m.PriceNew <= maxPrice) && (minPrice == 0 || m.PriceNew >= minPrice) && m.Name.Contains(name) ).CountAsync(); return(await query); }
public List <CustomerAppIG4Item> GetPrestigeForMap(double km, double Latitude, double Longitude, string name) { var query = from c in FDIDB.Customers where c.IsPrestige == true && (!c.IsDelete.HasValue || c.IsDelete == false) && (string.IsNullOrEmpty(name) || c.FullName.Contains(name)) && ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)(c.Latitude ?? 0), (float)(c.Longitude ?? 0)) / 1000 <= km orderby c.Ratings descending select new CustomerAppIG4Item { ID = c.ID, Fullname = c.FullName, Address = c.CustomerAddresses.Where(a => a.IsDefault == true).Select(a => a.Address).FirstOrDefault(), Ratings = c.Ratings, AvgRating = c.AvgRating, LikeTotal = c.LikeTotal, ImageTimeline = c.ImageTimeline, Longitude = c.Longitude, Latitude = c.Latitude, Km = ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) / 1000, }; return(query.ToList()); }
public List <CustomerAppIG4Item> GetPrestige(double Latitude, double Longitude, int page, int pagesize) { var query = from c in FDIDB.Customers where c.IsPrestige == true && (!c.IsDelete.HasValue || c.IsDelete == false) orderby c.Ratings descending select new CustomerAppIG4Item { ID = c.ID, Fullname = c.FullName, Address = c.Address, Ratings = c.Ratings, AvgRating = c.AvgRating, LikeTotal = c.LikeTotal, ImageTimeline = c.ImageTimeline, Longitude = c.Longitude, Latitude = c.Latitude, Km = ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) / 1000, }; query = query.Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }
public List <CustomerAppIG4Item> ListByMap(int km, float la, float lo) { var query = from c in FDIDB.Customers where c.Type == 2 && (km == 0 || ConvertUtil.DistanceBetween(la, lo, (float)c.Latitude, (float)c.Longitude) <= km) orderby c.Ratings descending select new CustomerAppIG4Item { ID = c.ID, Fullname = c.FullName, Address = c.Address, Ratings = c.Ratings, AvgRating = c.AvgRating, LikeTotal = c.LikeTotal, Latitude = c.Latitude, Longitude = c.Longitude, ImageTimeline = c.ImageTimeline, Description = c.Description, ListPId = c.Shop_Product_Detail.Where(m => !m.IsDelete.HasValue || !m.IsDelete.Value).Select(m => m.ID) }; return(query.ToList()); }
public List <ProductAppIG4Item> GetItemByCategoryId(List <int> ids, int maxKm, int minPrice, int maxPrice, double Latitude, double Longitude, int page, int pagesize) { var query = from c in FDIDB.Shop_Product where ids.Contains(c.CategoryId) && c.IsShow == true && (c.IsDelete == false) && (minPrice == 0 || c.PriceNew >= minPrice) && (maxPrice == 0 || c.PriceNew <= maxPrice) && (maxKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) <= maxKm) select new ProductAppIG4Item { ID = c.ID, Name = c.Name, PriceNew = c.PriceNew, Ratings = c.Ratings ?? 0, AvgRating = c.AvgRating ?? 0, UrlPicture = c.Gallery_Picture.Folder + c.Gallery_Picture.Url, Latitude = c.Latitude, Longitude = c.Longitude }; query = query.OrderByDescending(m => m.AvgRating).ThenByDescending(m => m.Ratings); query = query.Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }
public List <CustomerAppIG4Item> GetCustomerForMap(double km, double Latitude, double Longitude, int page, int pagesize) { var query = from c in FDIDB.Customers join a in FDIDB.CustomerAddresses on c.ID equals a.CustomerId where (!c.IsDelete.HasValue || c.IsDelete == false) && c.Type == 2 && a.IsDefault && ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)(a.Latitude ?? 0), (float)(a.Longitude ?? 0)) <= km select new CustomerAppIG4Item { ID = c.ID, UserName = c.UserName, Fullname = c.FullName, Address = c.CustomerAddresses.Where(g => g.IsDefault == true).Select(b => b.Address).FirstOrDefault(), Mobile = c.Mobile, AvartaUrl = c.AvatarUrl, Latitude = c.Latitude, Longitude = c.Longitude, Km = ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)a.Latitude, (float)a.Longitude) / 1000, ImageTimeline = c.ImageTimeline, }; query = query.OrderBy(m => m.Km).Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }
public List <ProductAppIG4Item> GetIsHotItemByCategoryId(int cateId, string name, double minKm, double maxKm, int minPrice, int maxPrice, double Latitude, double Longitude, int page, int pagesize) { var date = DateTime.Now.TotalSeconds(); var query = from c in FDIDB.Shop_Product_Detail where c.CateID == cateId && c.IsShow == true && c.IsDelete == false && c.IsHot == true && (maxKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) <= maxKm) && (minKm == 0 || ConvertUtil.DistanceBetween((float)Latitude, (float)Longitude, (float)c.Latitude, (float)c.Longitude) >= minKm) && (maxPrice == 0 || c.Price <= maxPrice) && (minPrice == 0 || c.Price >= minPrice) && c.Name.Contains(name) select new ProductAppIG4Item { ID = c.ID, Name = c.Name, Price = c.Price, UrlPicture = c.Gallery_Picture.Folder + c.Gallery_Picture.Url, Latitude = c.Latitude, Longitude = c.Longitude, }; query = query.OrderBy(m => m.Sort).OrderByDescending(m => m.AvgRating).ThenByDescending(m => m.Ratings); query = query.Skip(pagesize * (page - 1)).Take(pagesize); return(query.ToList()); }