Esempio n. 1
0
 public static List <OrderViewModel> SerializeOrdersToViewModels(IEnumerable <Order> orders)
 {
     return(orders.Select(order => new OrderViewModel
     {
         Id = order.Id,
         CreatedOn = order.DateCreated,
         UpdatedOn = order.DateUpdated,
         OrderItems = SerializeSalesOrderItems(order.OrderItems),
         Customer = CustomerMapping.SerializeCustomer(order.Customer),
         IsPaid = order.IsPaid
     }).ToList());
 }
Esempio n. 2
0
        public ActionResult CreateCustomer([FromBody] CustomerViewModel customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _logger.LogInformation("Creating a new customer");
            customer.DateCreated = DateTime.UtcNow;
            customer.DateUpdated = DateTime.UtcNow;
            var customerData = CustomerMapping.SerializeCustomer(customer);
            var newCustomer  = _customerService.CreateCustomer(customerData);

            return(Ok(newCustomer));
        }