public void AddImage(List<Image> images) { using(var context = new ECommerceDbDataContext(_conStr)) { context.Images.InsertAllOnSubmit(images); context.SubmitChanges(); } }
public void AddProduct(Product product) { using(var context = new ECommerceDbDataContext(_conStr)) { context.Products.InsertOnSubmit(product); context.SubmitChanges(); } }
public void AddCategory(Category category) { using(var context = new ECommerceDbDataContext(_conStr)) { context.Categories.InsertOnSubmit(category); context.SubmitChanges(); } }
public Cart CreateCart() { using(var context = new ECommerceDbDataContext(_conStr)) { Cart cart = new Cart(); cart.DateCreated = DateTime.Now; context.Carts.InsertOnSubmit(cart); context.SubmitChanges(); return cart; } }
public void AddUser(string username, string password) { string salt = PasswordHelper.GenerateRandomSalt(); string hash = PasswordHelper.HashPassword(password, salt); User user = new User { UserName = username, PasswordSalt = salt, PasswordHash = hash, }; using(var context = new ECommerceDbDataContext(_connectionString)) { context.Users.InsertOnSubmit(user); context.SubmitChanges(); } }
public void AddToCart(CartItem items) { using (var context = new ECommerceDbDataContext(_conStr)) { if(CheckIfItemIsAlreadyInCart(items)) { var updateItem = context.CartItems.Where(i => i.CartId == items.CartId && i.ProductId == items.ProductId).FirstOrDefault(); updateItem.Quantity += items.Quantity; } else { context.CartItems.InsertOnSubmit(items); } context.SubmitChanges(); } }
public void UpdateQuantity(int quantity, int itemId) { using (var context = new ECommerceDbDataContext(_conStr)) { var updateItem = context.CartItems.Where(i => i.CartItemsId == itemId).FirstOrDefault(); updateItem.Quantity = quantity; context.SubmitChanges(); } }