public void GetSpecificationByArticleId() { var logic = new ArticleLogic(new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext()); var listArticleOfBrand = logic.GetSpecsByArticleId(1); Assert.IsNotNull(listArticleOfBrand, "Getting specification of article failed"); }
public void GetArticlesByBrand() { var logic = new ArticleLogic(new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext()); var listArticleOfBrand = logic.GetArticlesByBrandId(1); Assert.IsNotNull(listArticleOfBrand, "Getting list of all articles by brand failed"); }
public void GetCategoryArticlesById() { var logic = new ArticleLogic(new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext()); var listArticlesByCatid = logic.GetArticlesByCatId(1); Assert.IsNotNull(listArticlesByCatid, "Getting articles by category id failed"); }
public void GetArticleById() { var logic = new ArticleLogic(new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext()); var article1 = logic.GetById(1); Assert.IsNotNull(article1, "Getting article by id failed"); }
public void GetAllBrands() { var logic = new ArticleLogic(new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext()); var listOfBrand = logic.GetAllBrands(); Assert.IsNotNull(listOfBrand, "Getting list of all brands failed"); }
/// <summary> /// The dispose. /// </summary> public void Dispose() { if (this._db != null) { this._db.Dispose(); this._db = null; } }
/// <summary> /// The update shopping cart database. /// </summary> /// <param name="cartId"> /// The cart id. /// </param> /// <param name="CartItemUpdates"> /// The cart item updates. /// </param> /// <exception cref="Exception"> /// </exception> public void UpdateShoppingCartDatabase(string cartId, ShoppingCartUpdates[] CartItemUpdates) { using ( var db = new ArticleLogic( new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext())) { try { var cartItemCount = CartItemUpdates.Count(); var myCart = this.GetCartItems(); foreach (var cartItem in myCart) { // Iterate through all rows within shopping cart list for (var i = 0; i < cartItemCount; i++) { if (cartItem.Product.Id == CartItemUpdates[i].ProductId) { if (CartItemUpdates[i].PurchaseQuantity < 1 || CartItemUpdates[i].RemoveItem == true) { this.RemoveItem(cartId, cartItem.ProductId); } else { this.UpdateItem(cartId, cartItem.ProductId, CartItemUpdates[i].PurchaseQuantity); } } } } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Database - " + exp.Message.ToString(), exp); } } }
/// <summary> /// The update item. /// </summary> /// <param name="updateCartID"> /// The update cart id. /// </param> /// <param name="updateProductID"> /// The update product id. /// </param> /// <param name="quantity"> /// The quantity. /// </param> /// <exception cref="Exception"> /// </exception> public void UpdateItem(string updateCartID, int updateProductID, int quantity) { using (var db = new ArticleLogic(new ArticleOracleContext(), new BrandOracleContext(), new CategoryOracleContext(), new SpecificationOracleContext())) { try { var myItem = (from c in db.ShoppingCartItems where c.CartId == updateCartID && c.Product.Id == updateProductID select c).FirstOrDefault(); if (myItem != null) { myItem.Quantity = quantity; db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp); } } }