public void AddPage(Page data)
 {
     using (ShoppingStoreContext Context = new ShoppingStoreContext())
     {
         Context.Page.Add(data);
         Context.SaveChanges();
     }
 }
Beispiel #2
0
 public void DeleteCatagory(int id)
 {
     using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext())
     {
         Category category = shoppingStoreContext.Catagories.Find(id);
         shoppingStoreContext.Catagories.Remove(category);
         shoppingStoreContext.SaveChanges();
     }
 }
Beispiel #3
0
        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();
     }
 }
Beispiel #5
0
 public void DeleteProduct(int id)
 {
     using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext())
     {
         Product product = shoppingStoreContext.Products.Find(id);
         shoppingStoreContext.Products.Remove(product);
         shoppingStoreContext.SaveChanges();
     }
 }
Beispiel #6
0
 public Product FindProduct(int id)
 {
     using (ShoppingStoreContext shoppingStoreContext = new ShoppingStoreContext())
     {
         Product product = shoppingStoreContext.Products.Find(id);
         shoppingStoreContext.SaveChanges();
         return(product);
     }
 }
Beispiel #7
0
        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();
            }
        }
Beispiel #9
0
 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");
     }
 }
Beispiel #10
0
 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);
     }
 }
Beispiel #11
0
        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);
            }
        }
Beispiel #13
0
        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++;
                }
            }
        }
Beispiel #16
0
        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);
        }
Beispiel #17
0
        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++;
                }
            }
        }