public Models.Customer ParseCustomer(Entities.Customer customer)
 {
     Models.Customer c = new Models.Customer();
     c.CustomerID = customer.CustomerId;
     c.Name       = customer.CustomerName;
     c.IsManager  = customer.IsManager;
     return(c);
 }
 public Entities.Customer ParseCustomer(Models.Customer customer)
 {
     Entities.Customer c = new Entities.Customer();
     if (customer.CustomerID != null)
     {
         c.CustomerId = (int)customer.CustomerID;
     }
     c.CustomerName = customer.Name;
     c.IsManager    = customer.IsManager;
     return(c);
 }
Example #3
0
 public int?AddCustomer(string name, Models.Customer customer)
 {
     Entities.Customer cEntity = mapper.ParseCustomer(customer);
     ctx.Customers.Add(cEntity);
     ctx.SaveChanges();
     using var log = new LoggerConfiguration()
                     .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day, shared: true)
                     .CreateLogger();
     log.Information("TRANSACTION: Created a new customer");
     return(cEntity.CustomerId);
 }
Example #4
0
 public Model.Customer ParseCustomer(Entities.Customer customer)
 {
     return(new Model.Customer
     {
         FName = customer.CustomerFname,
         LName = customer.CustomerLname,
         Username = customer.CustomerUsername,
         PasswordHash = customer.CustomerPasswordhash,
         CustomerID = customer.CustomerId
                      //Carts = ParseCart(customer.Carts.First());
                      //do i need to return lists of carts/orders? I'm not sure yet
     });
 }
Example #5
0
        public List <Order> GetOrdersWithCustomers()
        {
            //retrieve all orders from DB
            List <Order> orders = _context.Orders.Select(x => _mapper.ParseOrder(x)).ToList();

            // for each order in the new list
            foreach (Order order in orders)
            {
                //find the customer in the db that made said order
                Entity.Customer customer = _context.Customers.Find(order.CustomerID);
                //assign customer to order object
                order.Customer = _mapper.ParseCustomer(customer);
            }
            //return list of orders, now populated with customers who made them
            return(orders);
        }