public void AddPage(Page data) { using (ShoppingStoreContext Context = new ShoppingStoreContext()) { Context.Page.Add(data); Context.SaveChanges(); } }
public void DeleteCatagory(int id) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { Category category = shoppingStoreContext.Catagories.Find(id); shoppingStoreContext.Catagories.Remove(category); shoppingStoreContext.SaveChanges(); } }
public void SaveOrderDetails(OrderDetails order) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { shoppingStoreContext.OrderDetails.Add(order); shoppingStoreContext.SaveChanges(); } }
public void EditViewBar(SideBar sideBar) { using (ShoppingStoreContext Context = new ShoppingStoreContext()) { sideBar = Context.Bars.Find(1); sideBar.Body = sideBar.Body; Context.SaveChanges(); } }
public void DeleteProduct(int id) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { Product product = shoppingStoreContext.Products.Find(id); shoppingStoreContext.Products.Remove(product); shoppingStoreContext.SaveChanges(); } }
public Product FindProduct(int id) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { Product product = shoppingStoreContext.Products.Find(id); shoppingStoreContext.SaveChanges(); return(product); } }
public void SavePlaceOrder(Order order) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { shoppingStoreContext.Orders.Add(order); shoppingStoreContext.SaveChanges(); } }
public void DeletePage(int id, Page page) { using (ShoppingStoreContext Context = new ShoppingStoreContext()) { Context.Page.Remove(page); Context.SaveChanges(); } }
public Product UploadImage(int id) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { Product product = shoppingStoreContext.Products.Find(id); shoppingStoreContext.SaveChanges(); return(product); // product.Categories = new SelectList(shoppingStoreContext.Catagories.ToList(), "Id", "Name"); } }
public Category SaveProduct(Product product) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { Category category = shoppingStoreContext.Catagories.FirstOrDefault(x => x.Id == product.CatagoryId); shoppingStoreContext.Products.Add(product); shoppingStoreContext.SaveChanges(); return(category); } }
public Product UpdateProduct(int id, Product product) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { Product products = shoppingStoreContext.Products.Find(id); Category category = shoppingStoreContext.Catagories.FirstOrDefault(x => x.Id == product.CatagoryId); product.CatagoryName = category.Name; shoppingStoreContext.SaveChanges(); return(products); } }
public bool CheckTitle(int id, Page page) { bool status = false; using (ShoppingStoreContext Context = new ShoppingStoreContext()) { if (Context.Page.Where(findId => findId.Id != id).Any(findTitle => findTitle.Title == page.Title) || Context.Page.Where(findId => findId.Id != id).Any(findTitle => findTitle.Description == page.Description)) { status = true; Context.SaveChanges(); } return(status); } }
public bool AddNewCategory(string categoryname, Category category) { bool status = false; using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { if (shoppingStoreContext.Catagories.Any(x => x.Name == categoryname)) { status = true; } shoppingStoreContext.Catagories.Add(category); shoppingStoreContext.SaveChanges(); } return(status); }
public bool CreateAccount(User user) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { // Make sure username is unique bool status = false; // Make sure username is unique if (shoppingStoreContext.Users.Any(x => x.UserName.Equals(user.UserName))) { status = true; user.UserName = ""; // return View("CreateAccount", model); } // Add the DTO shoppingStoreContext.Users.Add(user); // Save shoppingStoreContext.SaveChanges(); // Add to UserRolesDTO int id = user.Id; UserRole userRoles = new UserRole() { UserId = id, RoleId = 2 }; shoppingStoreContext.UserRoles.Add(userRoles); shoppingStoreContext.SaveChanges(); return(status); } }
public void ReorderPages(int[] id) { using (ShoppingStoreContext Context = new ShoppingStoreContext()) { int count = 1; Page page; foreach (var pageId in id) { page = Context.Page.Find(pageId); page.Sorting = count; Context.SaveChanges(); count++; } } }
public bool RenameCategory(string newCategoryName, int id) { bool status = false; using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { if (shoppingStoreContext.Catagories.Any(x => x.Name == newCategoryName)) { status = true; } Category category = shoppingStoreContext.Catagories.Find(id); // Edit DTO category.Name = newCategoryName; category.Description = newCategoryName.Replace(" ", "-").ToLower(); // Save shoppingStoreContext.SaveChanges(); } return(status); }
public void ReorderCategories(int[] id) { using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext()) { // Set initial count int count = 1; // Declare PageDTO Category category; // Set sorting for each page foreach (var categoryId in id) { category = shoppingStoreContext.Catagories.Find(categoryId); category.Sorting = count; shoppingStoreContext.SaveChanges(); count++; } } }