public Cart AddCart(int CustomerID) { Entity.Cart newCart = new Entity.Cart(); newCart.CustomerId = CustomerID; _context.Carts.Add(newCart); _context.SaveChanges(); return(_mapper.ParseCart(newCart)); }
public Model.Cart ParseCart(Entities.Cart cart) { return(new Model.Cart { CartID = cart.CartId, customerID = cart.CustomerId }); }
public Cart FindCart(int customerID) { int customer = customerID; List <Entity.Cart> cartFound = _context.Carts.Where(x => x.CustomerId == customer).ToList(); if (cartFound.Count == 0) { Cart newCart = AddCart(customerID); return(newCart); } Entity.Cart finalCart = cartFound.First(); Model.Cart modelCart = _mapper.ParseCart(finalCart); return(modelCart); }