/// <summary> /// Request a list of all the products in the cart and prints them. /// </summary> private void ListAllItemsInCart() { Console.Clear(); Console.WriteLine(new string('-', 41)); Console.WriteLine(new string(' ', 13) + "GET PRICE TOTAL"); Console.WriteLine(new string('-', 41) + '\n'); Console.WriteLine(CartBusiness.ListAllItemsInCart(UserBusiness.GetID(username)) + '\n'); Console.ReadKey(); }
/// <summary> /// delete Product from cart /// input:ProductId /// </summary> /// <param name="Id"></param> /// <returns>view for cart</returns> public ActionResult DeleteCartVariant(Guid Id) { CartBusiness cartBusiness = new CartBusiness(); Guid CartId = new Guid(Session["userId"].ToString()); try { cartBusiness.DeleteCartVariant(Id, CartId); return(RedirectToAction("GetCart", "Cart")); } catch (Exception) { return(RedirectToAction("ErrorViewShow", "HttpErrors", new { msg = "cannot delete Some Internal error" })); } }
/// <summary> /// Request to remove a product from the cart of the user. /// </summary> private void RemoveItem() { Console.Clear(); Console.WriteLine(new string('-', 41)); Console.WriteLine(new string(' ', 15) + "REMOVE ITEM"); Console.WriteLine(new string('-', 41) + '\n'); Console.Write("Product Name: "); string productName = Console.ReadLine(); Console.WriteLine(); CartBusiness.RemoveItem(UserBusiness.GetID(username), ProductBusiness.GetID(productName)); }
/// <summary> /// get the all product aviable in the cart /// </summary> /// <returns>view cart details</returns> public ActionResult GetCart() { Guid UserID = new Guid(Session["userId"].ToString()); CartBusiness cartBusiness = new CartBusiness(); CartsVariantDTO data = cartBusiness.GetCartByUserId(UserID); var cartViewConfig = new MapperConfiguration(cfg => { cfg.CreateMap <CartsVariantDTO, CartViewModel>(); cfg.CreateMap <CartVariantDTO, VariantCartViewModel>(); cfg.CreateMap <VariantDTO, VariantViewModel>(); cfg.CreateMap <ProductDTO, ProductViewModel>(); }); IMapper cartDataMapper = new Mapper(cartViewConfig); CartViewModel viewData = cartDataMapper.Map <CartsVariantDTO, CartViewModel>(data); return(View(viewData)); }
public Cart AddCart(Cart cart) { try { var bc = new CartBusiness(); return(bc.Create(cart)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, Content = new StringContent(ex.Message + "+" + ex.InnerException), }; throw new HttpResponseException(httpError); } }
public Cart Add(Cart cart) { try { var cartbs = new CartBusiness(); return(cartbs.nuevo(cart)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public void Edit(CartItemDTO CartItemDTO) { try { var bc = new CartBusiness(); bc.Edit(CartItemDTO); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public Cart Find(int id) { try { var bc = new CartBusiness(); return(bc.GetById(id)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public List <Cart> List() { try { var cartbs = new CartBusiness(); return(cartbs.ListarTodas()); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public Cart Find(int id) { try { var bc = new CartBusiness(); return(bc.GetById(id)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, Content = new StringContent(ex.Message), }; throw new HttpResponseException(httpError); } }
public Cart GetbyCookie(string cookie) { try { var cartbs = new CartBusiness(); return(cartbs.GetbyCookie(cookie)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public void Remove(int id) { try { var bc = new CartBusiness(); bc.Remove(id); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public void Edit(Cart cart) { try { var bc = new CartBusiness(); bc.EditarCarrito(cart); } catch (Exception ex) { // Repack to Http error. var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public CartItemDTO Add(CartItemDTO CartItemDTO) { try { //instancia de la business var bc = new CartBusiness(); return(bc.Add(CartItemDTO)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public void Edit(Cart cart) { try { var bc = new CartBusiness(); bc.EditProduct(cart); } catch (Exception ex) { // Repack to Http error. var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, Content = new StringContent(ex.Message), }; throw new HttpResponseException(httpError); } }
public void Edit(Cart cart) { try { var bc = new CartBusiness(); cart.ChangedOn = System.DateTime.Now; bc.Edit(cart); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public void Remove(int id) { try { var cartbs = new CartBusiness(); var cart = cartbs.GetbyID(id); cartbs.Borrar(cart); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public AllResponse All() { try { var response = new AllResponse(); var bc = new CartBusiness(); response.ResultCartItemDTO = bc.All(); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public FindResponseCart Find(int id) { try { var response = new FindResponseCart(); var bc = new CartBusiness(); response.Result = bc.Find(id); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public FindCartResponse FindByCookie() { try { var cookie = Request.Headers.GetCookies("cart")[0]; var response = new FindCartResponse(); var bc = new CartBusiness(); response.Result = bc.FindByCookie(cookie["cart"].Value); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public ActionResult AddItem([Bind(Include = "Quantity,VariantID")] CartVariantViewModel cartVariantViewModel) { var cartViewConfig = new MapperConfiguration(cfg => { cfg.CreateMap <CartVariantViewModel, CartVariantDTO>(); }); IMapper cartDataMapper = new Mapper(cartViewConfig); CartVariantDTO cartItemDTO = new CartVariantDTO(); try { cartItemDTO = cartDataMapper.Map <CartVariantViewModel, CartVariantDTO>(cartVariantViewModel); cartItemDTO.CartID = new Guid(Session["userId"].ToString()); CartBusiness cartBusiness = new CartBusiness(); bool isproductAdd = cartBusiness.AddItemCart(cartItemDTO); return(RedirectToAction("GetCart", "Cart")); } catch (Exception) { return(RedirectToAction("ErrorViewShow", "HttpErrors", new { msg = "order Limit For Product is Excedd" })); } }
/// <summary> /// Prints all available products in the system and makes the user chose which one he wants to add to his cart. /// </summary> private void AddItem() { Console.Clear(); Console.WriteLine(ProductBusiness.GetAllProducts()); Console.ReadKey(); Console.Clear(); Console.WriteLine(new string('-', 40)); Console.WriteLine(new string(' ', 16) + "ADD ITEM"); Console.WriteLine(new string('-', 40) + '\n'); string name; while (true) { Console.Write("Product name: "); name = Console.ReadLine(); Console.WriteLine(); if (ProductBusiness.CheckForProduct(ProductBusiness.GetID(name))) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid name!"); Console.WriteLine(new string('-', 26) + '\n'); } Console.Write("Amount of this product: "); int amount = int.Parse(Console.ReadLine()); CartBusiness.AddItem(UserBusiness.GetID(username), ProductBusiness.GetID(name), amount); }