public void Update(Brand item) { try { var brand = _yapartStoreContext.Brands.FirstOrDefault(br => br.Id == item.Id); if (brand != null) { bool isModefied = false; if (brand.Name == item.Name) { brand.Name = item.Name; isModefied = true; } if (isModefied) { _yapartStoreContext.Entry(brand).State = EntityState.Modified; _yapartStoreContext.SaveChanges(); } } } catch (Exception e) { throw e; } }
public void Update(Category item) { try { var category = _yapartStoreContext.Categories.FirstOrDefault(br => br.Id == item.Id); if (category != null) { bool isModefied = false; if (category.Name == item.Name) { category.Name = item.Name; isModefied = true; } if (category.SectionId == item.SectionId) { category.SectionId = item.SectionId; isModefied = true; } if (isModefied) { _yapartStoreContext.Entry(category).State = EntityState.Modified; _yapartStoreContext.SaveChanges(); } } } catch (Exception e) { throw e; } }
public void Update(Group item) { try { var group = _yapartStoreContext.Groups.FirstOrDefault(br => br.Id == item.Id); if (group != null) { bool isModefied = false; if (group.Name == item.Name) { group.Name = item.Name; isModefied = true; } if (isModefied) { _yapartStoreContext.Entry(group).State = EntityState.Modified; _yapartStoreContext.SaveChanges(); } } } catch (Exception e) { throw e; } }
public void Update(Section item) { try { var section = _yapartStoreContext.Sections.FirstOrDefault(br => br.Id == item.Id); if (section != null) { bool isModefied = false; if (section.Name == item.Name) { section.Name = item.Name; isModefied = true; } if (section.GroupId == item.GroupId) { section.GroupId = item.GroupId; isModefied = true; } if (isModefied) { _yapartStoreContext.Entry(section).State = EntityState.Modified; _yapartStoreContext.SaveChanges(); } } } catch (Exception e) { throw e; } }
public void Update(Product item) { try { var product = _yapartStoreContext.Products.FirstOrDefault(br => br.Id == item.Id); if (product != null) { bool isModefied = false; if (product.Article == item.Article) { product.Article = item.Article; isModefied = true; } if (product.Descriptions == item.Descriptions) { product.Descriptions = item.Descriptions; isModefied = true; } if (product.Price == item.Price) { product.Price = item.Price; isModefied = true; } if (product.BrandId == item.BrandId) { product.BrandId = item.BrandId; isModefied = true; } if (product.CategoryId == item.CategoryId) { product.CategoryId = item.CategoryId; isModefied = true; } if (isModefied) { _yapartStoreContext.Entry(product).State = EntityState.Modified; _yapartStoreContext.SaveChanges(); } } } catch (Exception e) { throw e; } }
public void ChangeNameForLink() { var nullModificationsUrl = _yapartStoreContext.Modifications; if (nullModificationsUrl.Any()) { foreach (var modification in nullModificationsUrl) { modification.Url = modification.Name .Trim() .Replace("/", "") .Replace("рестайлинг", "restyling") .Replace(" ", "-") .ToLower(); _yapartStoreContext.Entry(modification).State = EntityState.Modified; } _yapartStoreContext.SaveChanges(); } }