public void updatenameasi() { var query = (from c in FDIDB.Categories select c).ToList(); foreach (var itemCategory in query) { itemCategory.Slug = FDIUtils.Slug(FDIUtils.NewUnicodeToAscii(itemCategory.Name)); } Save(); }
public List <ProductAppIG4Item> GetCategoryForMap(string name, double minKm, double maxKm, int minPrice, int maxPrice, int categoryId, double Latitude, double Longitude) { if (!string.IsNullOrEmpty(name)) { name = String.Join(",", FDIUtils.Slug(FDIUtils.NewUnicodeToAscii(name)).Split('_').ToList()); } var query = from p in FDIDB.ShopMap(name, maxKm, minKm, categoryId, Latitude, Longitude, minPrice, maxPrice) select new ProductAppIG4Item { Longitude = p.Longitude ?? 0, Latitude = p.Latitude ?? 0, CustomerId = p.CustomerId, IsPrestige = p.IsPrestige, UrlPicture = p.UrlIcon, Sort = p.sortut }; return(query.ToList()); }
public List <ProductAppIG4Item> GetProductForMap(string name, double minKm, double maxKm, int cateid, int minPrice, int maxPrice, double Latitude, double Longitude, int page, int pagesize, bool HasTransfer, int shopid) { if (!string.IsNullOrEmpty(name)) { name = String.Join(",", FDIUtils.Slug(FDIUtils.NewUnicodeToAscii(name)).Split('_').ToList()); } var query = FDIDB.ProductFull(name, maxKm, minKm, cateid, Latitude, Longitude, minPrice, maxPrice, page, pagesize, HasTransfer, shopid) .Select(l => new ProductAppIG4Item { ID = l.id ?? 0, Name = l.Name, PriceNew = l.PriceNew, UrlPicture = l.Folder + l.Url, kc = l.kc, IsPrestige = l.IsPrestige, IsPrestige1 = l.IsPrestige1, CateId = l.CateId, Km = l.km, Sort = l.sort }); return(query.ToList()); }
public async Task <ActionResult> Add() { var model = new ProductAppIG4Item(); UpdateModel(model); List <Gallery_Picture> images = new List <Gallery_Picture>(); for (int i = 0; i < Request.Files.Count; i++) { var img = await UploadImage(i); if (img.Code != 200) { return(Json(img)); } var picture = new Gallery_Picture { Type = !string.IsNullOrEmpty(Request["type"]) ? Convert.ToInt32(Request["type"]) : 0, CategoryID = model.CateId, Folder = img.Data.Folder, Name = img.Data.Name, DateCreated = DateTime.Now.TotalSeconds(), IsShow = true, Url = img.Data.Url, IsDeleted = false, }; images.Add(picture); _da.Add(picture); } if (images.Count == 0) { return(Json(new JsonMessage(1000, "Ảnh sản phẩn không được để trống."))); } await _da.SaveAsync(); //lay address var address = customerAddressDA.GetById(model.AddressId, CustomerId); if (address == null) { return(Json(new JsonMessage(1000, "Địa chỉ không tồn tại."))); } var product = new Shop_Product { Name = model.Name, NameAscii = FDIUtils.Slug(FDIUtils.NewUnicodeToAscii(model.Name)), Quantity = model.Quantity, Description = model.Description, PriceNew = model.PriceNew, PictureID = images[0].ID, CustomerID = CustomerId, freeShipFor = model.freeShipFor, HasTransfer = model.HasTransfer, Type = model.Type, IsShow = true, IsDelete = false, AddressId = address.ID, Latitude = address.Latitude.Value, CategoryId = model.CateId.Value, Longitude = address.Longitude.Value, DateCreated = DateTime.Now.TotalSeconds(), CustomerID1 = model.CustomerId1, //Gallery_Picture1 = _productDa.GetListPictureByArrId(images.Select(m => m.ID).ToList()), }; //product.Categories = _productDa.GetListCategoryByArrId(new List<int>() { model.CateId.Value }); _productDa.Add(product); await _productDa.SaveAsync(); return(Json(new JsonMessage(200, ""), JsonRequestBehavior.AllowGet)); }