示例#1
0
 public Cart AddCart(int CustomerID)
 {
     Entity.Cart newCart = new Entity.Cart();
     newCart.CustomerId = CustomerID;
     _context.Carts.Add(newCart);
     _context.SaveChanges();
     return(_mapper.ParseCart(newCart));
 }
示例#2
0
 public Model.Cart ParseCart(Entities.Cart cart)
 {
     return(new Model.Cart
     {
         CartID = cart.CartId,
         customerID = cart.CustomerId
     });
 }
示例#3
0
        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);
        }