public BrandsResponse Post(Brands request) { if (request.Brand.Id > 0) { Bm2s.Data.Common.BLL.Article.Brand item = Datas.Instance.DataStorage.Brands[request.Brand.Id]; item.Code = request.Brand.Code; item.EndingDate = request.Brand.EndingDate; item.Name = request.Brand.Name; item.StartingDate = request.Brand.StartingDate; Datas.Instance.DataStorage.Brands[request.Brand.Id] = item; } else { Bm2s.Data.Common.BLL.Article.Brand item = new Data.Common.BLL.Article.Brand() { Code = request.Brand.Code, EndingDate = request.Brand.EndingDate, Name = request.Brand.Name, StartingDate = request.Brand.StartingDate }; Datas.Instance.DataStorage.Brands.Add(item); request.Brand.Id = item.Id; } BrandsResponse response = new BrandsResponse(); response.Brands.Add(request.Brand); return response; }
public BrandsResponse Delete(Brands request) { Bm2s.Data.Common.BLL.Article.Brand item = Datas.Instance.DataStorage.Brands[request.Brand.Id]; item.EndingDate = DateTime.Now; Datas.Instance.DataStorage.Brands[item.Id] = item; BrandsResponse response = new BrandsResponse(); response.Brands.Add(request.Brand); return response; }
public BrandsResponse Get(Brands request) { BrandsResponse response = new BrandsResponse(); List<Bm2s.Data.Common.BLL.Article.Brand> items = new List<Data.Common.BLL.Article.Brand>(); if (!request.Ids.Any()) { items.AddRange(Datas.Instance.DataStorage.Brands.Where(item => (string.IsNullOrWhiteSpace(request.Code) || item.Code.ToLower().Contains(request.Code.ToLower())) && (string.IsNullOrWhiteSpace(request.Name) || item.Name.ToLower().Contains(request.Name.ToLower())) && (!request.Date.HasValue || (request.Date >= item.StartingDate && (!item.EndingDate.HasValue || request.Date < item.EndingDate.Value))) )); } else { items.AddRange(Datas.Instance.DataStorage.Brands.Where(item => request.Ids.Contains(item.Id))); } var collection = (from item in items select new Bm2s.Poco.Common.Article.Brand() { Code = item.Code, EndingDate = item.EndingDate, Id = item.Id, Name = item.Name, StartingDate = item.StartingDate }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder); response.ItemsCount = collection.Count(); if (request.PageSize > 0) { response.Brands.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize)); } else { response.Brands.AddRange(collection); } try { response.PagesCount = collection.Count() / response.Brands.Count + (collection.Count() % response.Brands.Count > 0 ? 1 : 0); } catch { response.PagesCount = 1; } return response; }
private void Brands_Click(object sender, RoutedEventArgs e) { Brands add = new Brands(); add.Show(); }
/// <summary> /// 搜索 /// </summary> public ActionResult Search() { //搜索词 string keyword = WebHelper.GetQueryString("keyword"); WorkContext.SearchWord = WebHelper.HtmlEncode(keyword); if (keyword.Length == 0) { return(PromptView(WorkContext.UrlReferrer, "请输入搜索词")); } if (!SecureHelper.IsSafeSqlString(keyword)) { return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在")); } //异步保存搜索历史 Asyn.UpdateSearchHistory(WorkContext.Uid, keyword); //判断搜索词是否为分类名称,如果是则重定向到分类页面 int cateId = Categories.GetCateIdByName(keyword); if (cateId > 0) { return(Redirect(Url.Action("category", new RouteValueDictionary { { "cateId", cateId } }))); } else { cateId = WebHelper.GetQueryInt("cateId"); } //分类列表 List <CategoryInfo> categoryList = null; //分类信息 CategoryInfo categoryInfo = null; //品牌列表 List <BrandInfo> brandList = null; //品牌id int brandId = Brands.GetBrandIdByName(keyword); if (brandId > 0)//当搜索词为品牌名称时 { //获取品牌相关的分类 categoryList = Brands.GetBrandCategoryList(brandId); //由于搜索结果的展示是以分类为基础的,所以当分类不存在时直接将搜索结果设为“搜索的商品不存在” if (categoryList.Count == 0) { return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在")); } if (cateId > 0) { categoryInfo = Categories.GetCategoryById(cateId); } else { //当没有进行分类的筛选时,将分类列表中的首项设为当前选中的分类 categoryInfo = categoryList[0]; cateId = categoryInfo.CateId; } brandList = new List <BrandInfo>(); brandList.Add(Brands.GetBrandById(brandId)); } else//当搜索词为商品关键词时 { //获取商品关键词相关的分类 categoryList = Searches.GetCategoryListByKeyword(keyword); //由于搜索结果的展示是以分类为基础的,所以当分类不存在时直接将搜索结果设为“搜索的商品不存在” if (categoryList.Count == 0) { return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在")); } if (cateId > 0) { categoryInfo = Categories.GetCategoryById(cateId); } else { categoryInfo = categoryList[0]; cateId = categoryInfo.CateId; } //根据商品关键词获取分类相关的品牌 brandList = Searches.GetCategoryBrandListByKeyword(cateId, keyword); if (brandList.Count == 0) { return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在")); } brandId = WebHelper.GetQueryInt("brandId"); } //最后再检查一遍分类是否存在 if (categoryInfo == null) { return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在")); } //筛选价格 int filterPrice = WebHelper.GetQueryInt("filterPrice"); //筛选属性 string filterAttr = WebHelper.GetQueryString("filterAttr"); //是否只显示有货 int onlyStock = WebHelper.GetQueryInt("onlyStock"); //排序列 int sortColumn = WebHelper.GetQueryInt("sortColumn"); //排序方向 int sortDirection = WebHelper.GetQueryInt("sortDirection"); //当前页数 int page = WebHelper.GetQueryInt("page"); //分类筛选属性及其值列表 List <KeyValuePair <AttributeInfo, List <AttributeValueInfo> > > cateAAndVList = Categories.GetCategoryFilterAAndVList(cateId); //分类价格范围列表 string[] catePriceRangeList = StringHelper.SplitString(categoryInfo.PriceRange, "\r\n"); //筛选属性处理 List <int> attrValueIdList = new List <int>(); string[] filterAttrValueIdList = StringHelper.SplitString(filterAttr, "-"); if (filterAttrValueIdList.Length != cateAAndVList.Count)//当筛选属性和分类的筛选属性数目不对应时,重置筛选属性 { if (cateAAndVList.Count == 0) { filterAttr = "0"; } else { int count = cateAAndVList.Count; StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) { sb.Append("0-"); } filterAttr = sb.Remove(sb.Length - 1, 1).ToString(); } } else { foreach (string attrValueId in filterAttrValueIdList) { int temp = TypeHelper.StringToInt(attrValueId); if (temp > 0) { attrValueIdList.Add(temp); } } } //分页对象 PageModel pageModel = new PageModel(20, page, Searches.GetSearchMallProductCount(keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock)); //视图对象 MallSearchModel model = new MallSearchModel() { Word = keyword, CateId = cateId, BrandId = brandId, FilterPrice = filterPrice, FilterAttr = filterAttr, OnlyStock = onlyStock, SortColumn = sortColumn, SortDirection = sortDirection, CategoryList = categoryList, CategoryInfo = categoryInfo, BrandList = brandList, CatePriceRangeList = catePriceRangeList, AAndVList = cateAAndVList, PageModel = pageModel, ProductList = Searches.SearchMallProducts(pageModel.PageSize, pageModel.PageNumber, keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock, sortColumn, sortDirection) }; return(View(model)); }
public async Task <IActionResult> EditPost(Brands brand) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ModelState.AddModelError("", "Xaiş olunur düzgün doldurun."); ViewBag.Floor = _context.Floor; ViewBag.User = _userManager.Users; ViewBag.Tag = _context.Tags.Where(t => t.CategoryId == 2); return(View(brand)); } Brands newBrand = await _context.Brands.FindAsync(brand.Id); if (newBrand == null) { return(View("Error")); } if (brand.Photo != null) { string computerPhoto = Path.Combine(_env.WebRootPath, "img", newBrand.PhotoURL); if (System.IO.File.Exists(computerPhoto)) { System.IO.File.Delete(computerPhoto); } string filename = await brand.Photo.SaveAsync(_env.WebRootPath); brand.PhotoURL = filename; newBrand.PhotoURL = brand.PhotoURL; } IEnumerable <BrandTags> oldTags = _context.BrandTags.Where(p => p.BrandId == newBrand.Id); if (brand.TagsId != null) { _context.BrandTags.RemoveRange(oldTags); foreach (var c in brand.TagsId) { BrandTags brandTags = new BrandTags() { BrandId = newBrand.Id, TagsId = c }; await _context.BrandTags.AddAsync(brandTags); } } newBrand.Name = brand.Name; newBrand.Phone = brand.Phone; newBrand.InstagramLink = brand.InstagramLink; newBrand.FacebookLink = brand.FacebookLink; newBrand.FloorId = brand.FloorId; newBrand.Website = brand.Website; newBrand.UserId = brand.UserId; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ICarBuilder WithBrand(Brands brand) { _car.Brand = brand; return(this); }
public List <Brand> GetBrands() { return(Brands.ToList()); }
private void DeleteBrandsAndSellersWithNoProducts() { Sellers.RemoveAll(s => s.Products.Count == 0); Brands.RemoveAll(s => s.Products.Count == 0); }
public IResult Delete(Brands brand) { _brandDal.Delete(brand); return(new SuccessResult()); }
public async Task <Response> Index(bool publishingCompany, bool books, bool authors, bool genres, bool series, int numBrands) { Response response = new Response(); Brands <Brand> brands = new Brands <Brand>(); try { if (numBrands == 0) { brands.Incorporate( await Context.Brand.OrderBy(x => x.Name) .Include(x => x.Avatar) .ToListAsync() ); } else { brands.Incorporate( await Context.Brand.OrderBy(x => x.Name) .Include(x => x.Avatar) .Take(numBrands) .ToListAsync() ); } if (series) { brands.Union( await Context.Brand.Include(x => x.BrandsSeries) .ThenInclude(y => y.Series) .ToListAsync() ); brands.Series(); } if (authors) { brands.Union( await Context.Brand.Include(x => x.BrandsAuthors) .ThenInclude(y => y.Author) .ToListAsync() ); brands.Authors(); } if (genres) { brands.Union( await Context.Brand.Include(x => x.GenresBrands) .ThenInclude(y => y.Genre) .ToListAsync() ); brands.Genres(); } if (publishingCompany) { brands.Union( await Context.Brand.Include(x => x.PublishingCompany) .ToListAsync() ); } if (books) { brands.Union( await Context.Brand.Include(x => x.Books) .ThenInclude(y => y.Cover) .ToListAsync() ); } response.Brands = brands; } catch (Exception ex) { response.Message = ex.Message; response.BadRequest = true; } return(response); }
public HttpResponseMessage Post([FromUri] Brands brand) { brands.Add(brand); return(Request.CreateResponse(HttpStatusCode.OK, brand)); }
public void Update(Brands item) { throw new NotImplementedException(); }
public async Task <IActionResult> Import(IFormFile fileExcel) { if (ModelState.IsValid) { if (fileExcel != null) { List <Brands> addedBrands = new List <Brands>(); List <Types> addedTypes = new List <Types>(); List <Materials> addedMaterials = new List <Materials>(); List <Forms> addedForms = new List <Forms>(); List <Guitars> addedGuitars = new List <Guitars>(); using (var stream = new FileStream(fileExcel.FileName, FileMode.Create)) { await fileExcel.CopyToAsync(stream); using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled)) { //перегляд усіх листів (в даному випадку категорій) foreach (IXLWorksheet worksheet in workBook.Worksheets) { //worksheet.Name - назва категорії. Пробуємо знайти в БД, якщо відсутня, то створюємо нову Brands newbrand; var b = (from br in _context.Brands where br.Name.Contains(worksheet.Name) select br).ToList(); if (b.Count > 0) { newbrand = b[0]; } else { newbrand = new Brands(); newbrand.Name = worksheet.Name; newbrand.Country = "Ukraine"; addedBrands.Add(newbrand); //додати в контекст _context.Brands.Add(newbrand); } //перегляд усіх рядків foreach (IXLRow row in worksheet.RowsUsed()) { try { Guitars guitar = new Guitars(); var guitars = (from g in _context.Guitars where g.Name.Contains(row.Cell(1).Value.ToString()) select g).ToList(); if (guitars.Count > 0) { continue; } else { guitar.Name = row.Cell(1).Value.ToString(); guitar.Brand = newbrand; guitar.Cost = Convert.ToInt32(row.Cell(2).Value); guitar.Year = Convert.ToInt32(row.Cell(3).Value); guitar.Info = "from excel"; //у разі наявності автора знайти його, у разі відсутності - додати Forms form; var forms = (from f in _context.Forms where f.Name.Contains(row.Cell(4).Value.ToString()) select f).ToList(); if (forms.Count > 0) { form = forms[0]; } else { form = new Forms(); form.Name = row.Cell(4).Value.ToString(); addedForms.Add(form); _context.Forms.Add(form); } guitar.Form = form; Materials material; var materials = (from m in _context.Materials where m.Name.Contains(row.Cell(5).Value.ToString()) select m).ToList(); if (materials.Count > 0) { material = materials[0]; } else { material = new Materials(); material.Name = row.Cell(5).Value.ToString(); addedMaterials.Add(material); _context.Materials.Add(material); } guitar.Material = material; Types type; var types = (from t in _context.Types where t.Name.Contains(row.Cell(6).Value.ToString()) select t).ToList(); if (types.Count > 0) { type = types[0]; } else { type = new Types(); type.Name = row.Cell(6).Value.ToString(); addedTypes.Add(type); _context.Types.Add(type); } guitar.Type = type; addedGuitars.Add(guitar); _context.Guitars.Add(guitar); await _context.SaveChangesAsync(); } } catch (Exception e) { //logging самостійно :) throw new Exception("Text with context data", e); } } } } } MemoryStream memory = new MemoryStream(); using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(memory, WordprocessingDocumentType.Document)) { // Add a main document part. MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); // Create the document structure and add some text. mainPart.Document = new Document(); Body body = mainPart.Document.AppendChild(new Body()); Paragraph para = body.AppendChild(new Paragraph()); Run run = para.AppendChild(new Run()); run.AppendChild(new Text("Added " + addedBrands.Count.ToString() + " Brands: ")); foreach (Brands b in addedBrands) { run.AppendChild(new Text(b.Name + ", ")); } run.AppendChild(new Break()); run.AppendChild(new Text("Added " + addedTypes.Count.ToString() + " Types: ")); foreach (Types t in addedTypes) { run.AppendChild(new Text(t.Name + ", ")); } run.AppendChild(new Break()); run.AppendChild(new Text("Added " + addedForms.Count.ToString() + " Forms: ")); foreach (Forms f in addedForms) { run.AppendChild(new Text(f.Name + ", ")); } run.AppendChild(new Break()); run.AppendChild(new Text("Added " + addedMaterials.Count.ToString() + " Materials: ")); foreach (Materials m in addedMaterials) { run.AppendChild(new Text(m.Name + ", ")); } run.AppendChild(new Break()); run.AppendChild(new Text("Added " + addedGuitars.Count.ToString() + " Guitars: ")); foreach (Guitars g in addedGuitars) { run.AppendChild(new Text(g.Name + ", ")); } mainPart.Document.Save(); } memory.Seek(0, SeekOrigin.Begin); return(File(memory, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Report.docx")); } } return(RedirectToAction(nameof(Index))); }
public IResult Update(Brands brand) { _brandDal.Update(brand); return(new SuccessResult()); }
//more build methods for setting specific parameters public TV BuildTV (Brands thisKind, string Size) { ... }
public List <Models> GetModels(Brands brands) { return(modelsManagement.GetModels(brands)); }
public Brand GetBrand(string code) => Brands.FirstOrDefault(b => b.Code == code);
public IResult Add(Brands brand) { _brandDal.Add(brand); return(new SuccessResult()); }
public static void Initialize(TSContext context) { context.Database.EnsureCreated(); if (context.Brands.Any()) { return; } var providers = new Providers[] { new Providers { Name = "ANDRAX Co.", Address = "Україна" }, new Providers { Name = "JONNESWAY ENTERPRISE CO., LTD", Address = "Японія" }, new Providers { Name = "King Tony Co.", Address = "Японія" }, new Providers { Name = "Toptul Co., LTD", Address = "Китай" }, new Providers { Name = "JOBI", Address = "Польща" } }; foreach (Providers p in providers) { context.Providers.Add(p); } context.SaveChanges(); var brands = new Brands[] { new Brands { Name = "ANDRMAX", Info = "Заснований в 2002.", ProvidersID = 1 }, new Brands { Name = "Jonnesway", Info = "Заснований в 1982, в Україні з 2001.", ProvidersID = 2 }, new Brands { Name = "KingTony", Info = "Заснований в 1977, в Україні з 1998.", ProvidersID = 3 }, new Brands { Name = "Toptul", Info = "Заснований в 1998, в Україні з 2003.", ProvidersID = 4 }, new Brands { Name = "Jobi", Info = "Заснований в 1979, в Україні з 1995.", ProvidersID = 5 } }; foreach (Brands b in brands) { context.Brands.Add(b); } context.SaveChanges(); var products = new Products[] { new Products { Name = "Автообладнання", Price = 980, BrandsID = 1 }, new Products { Name = "Обладннаня для автомайстерні", Price = 875, BrandsID = 2 }, new Products { Name = "Ручний інструмент", Price = 754, BrandsID = 3 }, new Products { Name = "Компресори", Price = 7098, BrandsID = 4 }, new Products { Name = "професійний іструмент", Price = 907, BrandsID = 5 } }; foreach (Products pr in products) { context.Products.Add(pr); } context.SaveChanges(); var owners = new Owners[] { new Owners { Name = "Коломієць Анатолій Петрович", BrandsID = 1 }, new Owners { Name = "Павловська Юлія Олегівна", BrandsID = 2 }, new Owners { Name = "Мацута Ілья Борисович", BrandsID = 3 }, new Owners { Name = "Вишняков Сергій Дмит", BrandsID = 4 }, new Owners { Name = "Каролінська Наталія Федорівна", BrandsID = 5 } }; foreach (Owners o in owners) { context.Owners.Add(o); } context.SaveChanges(); var shops = new Shops[] { new Shops { Name = "ANRMAX", Address = "Київ, вулиця Шевченка 122", OwnersID = 1 }, new Shops { Name = "Jonnesway Ukraine", Address = "Київ, вулиця Ломоносова 76", OwnersID = 2 }, new Shops { Name = "KingTony UK", Address = "Львів, вулиця Леся Курбаса 12", OwnersID = 3 }, new Shops { Name = "Топтул", Address = "Київ, проспект Перемоги 67", OwnersID = 4 }, new Shops { Name = "Jo", Address = "Львів, вулиця Свободи 18", OwnersID = 5 } }; foreach (Shops s in shops) { context.Shops.Add(s); } context.SaveChanges(); }
public static RepoBrands FromBrandsToRepoBrands(this Brands item) { Mapper.Initialize(cfg => cfg.CreateMap <Brands, RepoBrands>() .ForMember(x => x.Cars, _ => _.Ignore())); return(Mapper.Map <Brands, RepoBrands>(item)); }
public InMemoryDatabase() { // Aldi tilbudsavis Products.Add(new Product("Solgryn", 28, "Ota", "Aldi")); Products.Add(new Product("XXL Schnitzel", 24, "Worlds kitchen", "Aldi")); Products.Add(new Product("Skæreost", 45, "Them", "Aldi")); Products.Add(new Product("Delikatesser", 10, "pålækker", "Aldi")); Products.Add(new Product("Jolly cola", 7, "jolly", "Aldi")); Products.Add(new Product("redbull", 39, "redbull", "Aldi")); Products.Add(new Product("Flødeboller", 20, "Samba", "Aldi")); Products.Add(new Product("Brødblandinger", 12, "Valsmøllen", "Aldi")); Products.Add(new Product("Bacon i skiver", 5, "Gierlinger", "Aldi")); Products.Add(new Product("Joe' kurt", 15, "naturli'", "Aldi")); Products.Add(new Product("Mælkesnitte", 15, "kinder", "Aldi")); Products.Add(new Product("Småkager", 10, "Nordthy", "Aldi")); Products.Add(new Product("Indbagt laksefilet", 20, "Rahbek", "Aldi")); Products.Add(new Product("Kalvecuvette", 45, "landlyst", "Aldi")); Products.Add(new Product("Hakket kød", 49, "landlyst", "Aldi")); Products.Add(new Product("minipizza", 10, "pigga", "Aldi")); Products.Add(new Product("Solsikkerugbrød", 12, "Kohberg", "Aldi")); Products.Add(new Product("Shampoo", 20, "head and shoulders", "Aldi")); Products.Add(new Product("Morgenmad", 35, "nestle", "Aldi")); Products.Add(new Product("Yoghurt", 14, "yoggi", "Aldi")); Products.Add(new Product("Smoothie", 10, "Froosh", "Aldi")); Products.Add(new Product("kartoffelsuppe", 12, "La finesse", "Aldi")); Products.Add(new Product("Ellebryg", 10, "Skovlyst", "Aldi")); Products.Add(new Product("markrelfilet", 45, "Sæby", "Aldi")); Products.Add(new Product("Original chips", 12, "pringles", "Aldi")); Products.Add(new Product("Bloklys", 18, "asp holmblad", "Aldi")); Products.Add(new Product("chelsea støvler", 139, "walkx", "Aldi")); Products.Add(new Product("Armbåndsur", 79, "krontaler", "Aldi")); Products.Add(new Product("Sengesæt", 129, "Quality textiles", "Aldi")); Products.Add(new Product("Stolehynder", 99, "Quality textiles", "Aldi")); Products.Add(new Product("kroge i træ", 49, "FSC", "Aldi")); // Fakta tilbudsavis Products.Add(new Product("Cheddar", 9, "Coop", "Fakta")); Products.Add(new Product("Brød", 12, "Schulstad", "Fakta")); Products.Add(new Product("Flødeboller", 19, "Spangsberg", "Fakta")); Products.Add(new Product("Løg", 6, "Coop", "Fakta")); Products.Add(new Product("Hel kylling", 45, "Rose", "Fakta")); Products.Add(new Product("Skæreost", 39, "thiese", "Fakta")); Products.Add(new Product("Skyr", 25, "365økologi", "Fakta")); Products.Add(new Product("Brutalis øl", 6, "Brutalis", "Fakta")); Products.Add(new Product("Jolly cola", 7, "Jolly", "Fakta")); Products.Add(new Product("Cocio original", 5, "Cocio", "Fakta")); Products.Add(new Product("Solgryn", 14, "Ota", "Fakta")); Products.Add(new Product("Franske valfer", 10, "karen volf", "Fakta")); Products.Add(new Product("SkildpAdde is", 25, "premier is", "Fakta")); Products.Add(new Product("Biksemad", 16, "steff houlberg", "Fakta")); Products.Add(new Product("forårsruller", 20, "Daloon", "Fakta")); Products.Add(new Product("honning", 15, "jakobsens", "Fakta")); Products.Add(new Product("markrelfilet", 12, "Amanda", "Fakta")); Products.Add(new Product("Smøreost", 9, "Philadelphia", "Fakta")); Products.Add(new Product("Karrysild", 10, "xtra", "Fakta")); Products.Add(new Product("Æbleskiver", 12, "coop", "Fakta")); Products.Add(new Product("Chokoladerulle", 10, "marabou", "Fakta")); Products.Add(new Product("Klinkerens", 15, "ajax", "Fakta")); Products.Add(new Product("Tandbørste", 20, "colgate", "Fakta")); // Netto tilbudsavis Products.Add(new Product("Bleer", 89, "Libero Touch", "Netto")); Products.Add(new Product("Coca Cola", 11, "Coca Cola", "Netto")); Products.Add(new Product("Hakket oksekød 14-18%", 15, "Velsmag", "Netto")); Products.Add(new Product("Cremefine", 5, "Cremefine", "Netto")); Products.Add(new Product("Tomatsauce", 9, "Dolmio", "Netto")); Products.Add(new Product("Toiletpapir", 10, "Godt papir", "Netto")); Products.Add(new Product("Hjemmesko", 20, "Spot-vare", "Netto")); Products.Add(new Product("Plastboks med låg", 35, "Spot-vare", "Netto")); Products.Add(new Product("Veggie Pålæg 70g", 8, "Den grønne slagter", "Netto")); Products.Add(new Product("Rullepølse 70g", 8, "Den grønne slagter", "Netto")); Products.Add(new Product("Kyllingebryst 70g", 8, "Den grønne slagter", "Netto")); Products.Add(new Product("Hel Kylling 1500g", 79, "Legismose", "Netto")); Products.Add(new Product("Hel Kylling 1350g", 29, "Velsmag", "Netto")); Products.Add(new Product("Torskefars", 15, "Havfisk", "Netto")); Products.Add(new Product("Laksefars", 15, "Havfisk", "Netto")); Products.Add(new Product("Asparges Suppe", 18, "Knorr", "Netto")); Products.Add(new Product("Karry Suppe", 18, "Knorr", "Netto")); Products.Add(new Product("Goulash Suppe", 18, "Knorr", "Netto")); Products.Add(new Product("Tomat Suppe", 18, "Knorr", "Netto")); Products.Add(new Product("Mozzarella", 10, "Galbani", "Netto")); Products.Add(new Product("Prosciutto Pizza", 20, "Premieur", "Netto")); Products.Add(new Product("Meat Speciale Pizza", 20, "Premieur", "Netto")); Products.Add(new Product("Mozzarella Pizza", 20, "Premieur", "Netto")); Products.Add(new Product("Multi Juice", 10, "Nikoline", "Netto")); Products.Add(new Product("Mountain Blast", 10, "Powerrade", "Netto")); Products.Add(new Product("Blue Keld B Free", 10, "Blue Keld", "Netto")); Products.Add(new Product("Vanilje Yoghurt", 9, "Cheasy", "Netto")); Products.Add(new Product("Skovbær Yoghurt", 9, "Cheasy", "Netto")); Products.Add(new Product("Jordbær & Rabarber Yoghurt", 9, "Cheasy", "Netto")); Products.Add(new Product("Natural Skyr", 19, "Legismose", "Netto")); Products.Add(new Product("Vanilje Skyr", 19, "Legismose", "Netto")); Products.Add(new Product("Pære & Banan Skyr", 19, "Legismose", "Netto")); foreach (var brand in Products.Select(product => product.Brand).Distinct()) { Brands.Add(new Brand { Name = brand, Products = Products.Where(prod => prod.Brand == brand).ToList() }); } foreach (var seller in Products.Select(product => product.Seller).Distinct()) { Sellers.Add(new Seller { Name = seller, Products = Products.Where(prod => prod.Seller == seller).ToList() }); } }
public async Task <IActionResult> EditPost(Products product) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ModelState.AddModelError("", "Xaiş olunur düzgün doldurun."); return(View(product)); } Products newProduct = await _context.Products.FindAsync(product.Id); Brands brand = await _context.Brands.FindAsync(newProduct.BrandsId); if (newProduct == null) { return(View("Error")); } if (product.AllPhotos != null) { IEnumerable <ProductPhoto> myPhoto = newProduct.Photos.Where(b => b.ProductsId == product.Id); foreach (var photo in myPhoto) { string computerPhoto = Path.Combine(_env.WebRootPath, "img", photo.PhotoURL); if (System.IO.File.Exists(computerPhoto)) { System.IO.File.Delete(computerPhoto); } _context.RemoveRange(myPhoto); } bool isMain = true; foreach (var p in product.AllPhotos) { if (p != null) { if (p.ContentType.Contains("image/")) { string filename = await p.SaveAsync(_env.WebRootPath); ProductPhoto img = new ProductPhoto() { ProductsId = newProduct.Id, PhotoURL = filename }; if (isMain == true) { img.IsMain = true; } isMain = false; await _context.ProductPhoto.AddAsync(img); } } } } newProduct.Name = product.Name; newProduct.Info = product.Info; newProduct.Price = product.Price; await _context.SaveChangesAsync(); return(RedirectToAction("Index", brand)); }
public void Add(Brand t) { Brands.Add(t); }
public async Task <IActionResult> Create(Products product) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ViewBag.Active = "Home"; ViewBag.Brand = _context.Brands.Where(b => b.Id == product.BrandsId); return(View(product)); } if (product.AllPhotos == null) { ViewBag.Active = "Home"; ViewBag.Brand = _context.Brands.Where(b => b.Id == product.BrandsId); ModelState.AddModelError("AllPhotos", "Xahiş olunur şəkil əlavə edin."); return(View(product)); } Products myProduct = new Products() { Name = product.Name, Price = product.Price, Info = product.Info, BrandsId = product.BrandsId }; await _context.Products.AddAsync(myProduct); bool isMain = true; foreach (var p in product.AllPhotos) { if (p != null) { if (p.ContentType.Contains("image/")) { string filename = await p.SaveAsync(_env.WebRootPath); ProductPhoto img = new ProductPhoto() { ProductsId = myProduct.Id, PhotoURL = filename }; if (isMain == true) { img.IsMain = true; } isMain = false; await _context.ProductPhoto.AddAsync(img); } } } Brands brand = await _context.Brands.FindAsync(product.BrandsId); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), brand)); }
private async Task FillPicker() { Brands brands = await ShoesRepository.GetShoeBrandsAsync(); BrandEntry.ItemsSource = brands.Result; }
public void SetItemDetails() { if (currentGroupItem == null || currentGroupItem.IsSpoof) { SelectedBrand = null; SelectedFreq = null; SelectedDeliveryMethod = null; SelectedPlatform = null; SelectedSpecialist = null; ContractName = null; if (ReportTypes != null) { ReportTypes.ForEach((thislist, thisreport) => RemoveWeakEventListener(thisreport, ReportListener)); ReportTypes = new ObservableReportTypes(safeReportTypes, true); ReportTypes.ForEach((thislist, thisreport) => AddWeakEventListener(thisreport, ReportListener)); } ClientLocations = null; RaisePropertyChanged("ReportTypes"); ReportText = "Select Report Types..."; return; } if (/*DB.Connnected &&*/ ReportTypes == null) { ReportTypes = new ObservableReportTypes(ReportTypesTarget.GetReportTypesAsList()); safeReportTypes = new ObservableReportTypes(ReportTypes, true); } if (CurrentGroupItem.ContractID == null) { ContractName = "No Contract assigned."; } else { Contract contract = ContractTarget.GetByContractID((int)CurrentGroupItem.ContractID); if (contract == null) { ContractName = "No contract found for this Group."; } else { ContractName = contract.DESCR; } } AddWeakEventListener(CurrentGroupItem, EncryptListener); IgReports = InvoiceGrpReportsTarget.GetById(currentGroupItem.InvoiceGrpId); foreach (ReportType reportType in ReportTypes) { foreach (InvoiceGrpReport igr in IgReports) { if (igr.REPORT_TYPE_ID == reportType.REPORT_TYPE_ID) { reportType.IsSelected = true; } else { reportType.IsSelected = false; } } } RaisePropertyChanged("ReportTypes"); base.ViewCore.UpdateCB(); SelectedSpecialist = (Specialists.First(ss => ss.Id == currentGroupItem.BillingSpecialistID) as BillingSpecialist); SelectedFreq = (Freqs.First(f => f.FREQ == currentGroupItem.BillingFrequency) as Freq); SelectedPlatform = (Platforms.First(p => p.PLATFORM == currentGroupItem.PrimaryPlatform) as Platform); SelectedDeliveryMethod = (DeliveryMethods.First(dm => dm.TheDeliveryMethod == currentGroupItem.DeliveryMethod) as DeliveryMethod); SelectedBrand = (Brands.FirstOrDefault(b => b.BRAND == currentGroupItem.Brand) as Brand); SelectedRemitTo = (RemitTos.First(r => r.REMIT_TO_ID == currentGroupItem.RemitToID) as RemitTo); SelectedInvoiceStyle = (InvoiceStyles.First(i => i.INVOICE_STYLE == currentGroupItem.InvoiceStyle) as InvoiceStyle); SelectedInvoiceGrpStatus = (InvoiceGrpStatuss.First(i => i.INVOICE_GRP_STATUS == currentGroupItem.InvoiceGroupStatus) as InvoiceGrpStatus); if (ClientLocations != null) { ClientLocations.CollectionChanged -= ClientLocCollectionChanged; } ClientLocations = ExtClientTarget.FetchLocations(CurrentGroupItem.InvoiceGrpId, true); ClientLocations.CollectionChanged += ClientLocCollectionChanged; currentGroupItem.Modified = false; GroupVM.EnablePicker = true; }
public async Task <IActionResult> Create(Brands brand) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ViewBag.Active = "Home"; ViewBag.Floor = _context.Floor; ViewBag.User = _userManager.Users; ViewBag.Tag = _context.Tags.Where(t => t.CategoryId == 2); return(View(brand)); } if (ModelState["Photo"].ValidationState == ModelValidationState.Invalid) { ViewBag.Active = "Home"; ViewBag.Floor = _context.Floor; ViewBag.User = _userManager.Users; ViewBag.Tag = _context.Tags.Where(t => t.CategoryId == 2); return(View(brand)); } if (!brand.Photo.IsImage()) { ViewBag.Active = "Home"; ViewBag.Floor = _context.Floor; ViewBag.User = _userManager.Users; ViewBag.Tag = _context.Tags.Where(t => t.CategoryId == 2); ModelState.AddModelError("Photo", "File type should be image"); return(View(brand)); } string filename = await brand.Photo.SaveAsync(_env.WebRootPath); brand.PhotoURL = filename; Brands newBrand = new Brands() { Name = brand.Name, Phone = brand.Phone, Website = brand.Website, FacebookLink = brand.FacebookLink, InstagramLink = brand.InstagramLink, CategoryId = 2, FloorId = brand.FloorId, PhotoURL = filename, UserId = brand.UserId, IsActive = true }; await _context.Brands.AddAsync(newBrand); foreach (var c in brand.TagsId) { BrandTags tags = new BrandTags() { BrandId = newBrand.Id, TagsId = c }; await _context.BrandTags.AddAsync(tags); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(ProColors colors) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ViewBag.Active = "Home"; ViewBag.Color = _context.Colors; ViewBag.Brand = _context.Brands.Where(b => b.Id == colors.BrandsId); ViewBag.Size = _context.Sizes; return(View(colors)); } if (colors.AllPhotos == null) { ViewBag.Active = "Home"; ViewBag.Color = _context.Colors; ViewBag.Size = _context.Sizes; ViewBag.Brand = _context.Brands.Where(b => b.Id == colors.BrandsId); ModelState.AddModelError("AllPhotos", "Xahiş olunur şəkil əlavə edin."); return(View(colors)); } Products myProduct = new Products() { Name = colors.Name, Info = colors.Info, Price = colors.Price, BrandsId = colors.BrandsId }; await _context.Products.AddAsync(myProduct); bool isMain = true; foreach (var p in colors.AllPhotos) { if (p != null) { if (p.ContentType.Contains("image/")) { string filename = await p.SaveAsync(_env.WebRootPath); ProductPhoto img = new ProductPhoto() { ProductsId = myProduct.Id, PhotoURL = filename }; if (isMain == true) { img.IsMain = true; } isMain = false; await _context.ProductPhoto.AddAsync(img); } } } foreach (var c in colors.ColorsId) { ProductColors proColors = new ProductColors() { ProductsId = myProduct.Id, ColorId = c }; await _context.ProductColors.AddAsync(proColors); } foreach (var s in colors.SizesId) { ProductSizes proSize = new ProductSizes() { ProductsId = myProduct.Id, SizesId = s }; await _context.ProductSizes.AddAsync(proSize); } Brands brand = await _context.Brands.FindAsync(myProduct.BrandsId); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { id = brand.Id })); }
/// <summary> /// 商品 /// </summary> public ActionResult Product() { //商品id int pid = GetRouteInt("pid"); if (pid == 0) { pid = WebHelper.GetQueryInt("pid"); } //判断商品是否存在 ProductInfo productInfo = Products.GetProductById(pid); if (productInfo == null) { return(PromptView("/", "你访问的商品不存在")); } //店铺信息 StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId); if (storeInfo.State != (int)StoreState.Open) { return(PromptView("/", "你访问的商品不存在")); } //商品存在时 ProductModel model = new ProductModel(); //商品id model.Pid = pid; //商品信息 model.ProductInfo = productInfo; //商品分类 model.CategoryInfo = Categories.GetCategoryById(productInfo.CateId); //商品品牌 model.BrandInfo = Brands.GetBrandById(productInfo.BrandId); //店铺信息 model.StoreInfo = storeInfo; //店长信息 model.StoreKeeperInfo = Stores.GetStoreKeeperById(storeInfo.StoreId); //店铺区域 model.StoreRegion = Regions.GetRegionById(storeInfo.RegionId); //店铺等级信息 model.StoreRankInfo = StoreRanks.GetStoreRankById(storeInfo.StoreRid); //商品图片列表 model.ProductImageList = Products.GetProductImageList(pid); //扩展商品属性列表 model.ExtProductAttributeList = Products.GetExtProductAttributeList(pid); //商品SKU列表 model.ProductSKUList = Products.GetProductSKUListBySKUGid(productInfo.SKUGid); //商品库存数量 model.StockNumber = Products.GetProductStockNumberByPid(pid); //单品促销 model.SinglePromotionInfo = Promotions.GetSinglePromotionByPidAndTime(pid, DateTime.Now); //买送促销活动列表 model.BuySendPromotionList = Promotions.GetBuySendPromotionList(productInfo.StoreId, pid, DateTime.Now); //赠品促销活动 model.GiftPromotionInfo = Promotions.GetGiftPromotionByPidAndTime(pid, DateTime.Now); //赠品列表 if (model.GiftPromotionInfo != null) { model.ExtGiftList = Promotions.GetExtGiftList(model.GiftPromotionInfo.PmId); } //套装商品列表 model.SuitProductList = Promotions.GetProductAllSuitPromotion(pid, DateTime.Now); //满赠促销活动 model.FullSendPromotionInfo = Promotions.GetFullSendPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now); //满减促销活动 model.FullCutPromotionInfo = Promotions.GetFullCutPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now); //广告语 model.Slogan = model.SinglePromotionInfo == null ? "" : model.SinglePromotionInfo.Slogan; //商品促销信息 model.PromotionMsg = Promotions.GeneratePromotionMsg(model.SinglePromotionInfo, model.BuySendPromotionList, model.FullSendPromotionInfo, model.FullCutPromotionInfo); //商品折扣价格 model.DiscountPrice = Promotions.ComputeDiscountPrice(model.ProductInfo.ShopPrice, model.SinglePromotionInfo); //关联商品列表 model.RelateProductList = Products.GetRelateProductList(pid); //用户浏览历史 model.UserBrowseHistory = BrowseHistories.GetUserBrowseHistory(WorkContext.Uid, pid); //商品咨询类型列表 model.ProductConsultTypeList = ProductConsults.GetProductConsultTypeList(); //更新浏览历史 if (WorkContext.Uid > 0) { Asyn.UpdateBrowseHistory(WorkContext.Uid, pid); } //更新商品统计 Asyn.UpdateProductStat(pid, WorkContext.RegionId); return(View(model)); }
public async Task <IActionResult> EditPost(ProColors color) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ViewBag.Color = _context.Colors; ViewBag.Size = _context.Sizes; ModelState.AddModelError("", "Xaiş olunur düzgün doldurun."); return(View(color)); } Products newProduct = await _context.Products.FindAsync(color.Id); Brands brand = await _context.Brands.FindAsync(newProduct.BrandsId); if (newProduct == null) { return(View("Error")); } if (color.AllPhotos != null) { IEnumerable <ProductPhoto> myPhoto = newProduct.Photos.Where(b => b.ProductsId == newProduct.Id); foreach (var photo in myPhoto) { string computerPhoto = Path.Combine(_env.WebRootPath, "img", photo.PhotoURL); if (System.IO.File.Exists(computerPhoto)) { System.IO.File.Delete(computerPhoto); } _context.RemoveRange(myPhoto); } bool isMain = true; foreach (var p in color.AllPhotos) { if (p != null) { if (p.ContentType.Contains("image/")) { string filename = await p.SaveAsync(_env.WebRootPath); ProductPhoto img = new ProductPhoto() { ProductsId = newProduct.Id, PhotoURL = filename }; if (isMain == true) { img.IsMain = true; } isMain = false; await _context.ProductPhoto.AddAsync(img); } } } } newProduct.Name = color.Name; newProduct.Info = color.Info; newProduct.Price = color.Price; IEnumerable <ProductColors> oldColors = _context.ProductColors.Where(p => p.ProductsId == newProduct.Id); IEnumerable <ProductSizes> oldSizes = _context.ProductSizes.Where(p => p.ProductsId == newProduct.Id); if (color.ColorsId != null) { _context.ProductColors.RemoveRange(oldColors); foreach (var c in color.ColorsId) { ProductColors proColors = new ProductColors() { ProductsId = newProduct.Id, ColorId = c }; await _context.ProductColors.AddAsync(proColors); } } if (color.SizesId != null) { _context.ProductSizes.RemoveRange(oldSizes); foreach (var s in color.SizesId) { ProductSizes proSize = new ProductSizes() { ProductsId = newProduct.Id, SizesId = s }; await _context.ProductSizes.AddAsync(proSize); } } await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { id = brand.Id })); }
static MainWindow() { phoneList = Phones.GetAllPhones(); brandInfoList = Brands.GetBrandInfos(); }
public IActionResult EditarBrand(int marcaId) { Brands brands = _context.Brands.Find(marcaId); return(View(brands)); }