public void AddOrder(AddOrderRequest request) { var customer = _customerManager.Get(request.CustomerIdentityTag); if (customer is null) { customer = new Entities.Customer { IdentityTag = request.CustomerIdentityTag, Email = request.CustomerEmail, Phone = request.CustomerPhone, FirstName = request.CustomerFirstname, LastName = request.CustomerLastname, Updated = DateTime.Now, CommunicationType = SystemDefaults.DefaultCommunicationType }; _customerManager.Create(customer); } var order = new Order { Created = _timeManager.Parse(request.CreationDate, SystemDefaults.DefaultFormat), Customer = customer, TotalAmount = request.TotalPrice, Catering = _cateringManager.Get(request.CateringId) ?? throw new AppException($"Caterign with '{request.CateringId}' doesn't exists") }; var orderItems = new List <OrderItem>(); foreach (var item in request.AddOrderRequestItems) { ItemCategory category; if ((category = _orderManager.GetCategory(item.CategoryId)) == null) { throw new AppException($"Category with '{item.CategoryId}' doesn't exists"); } var t = new OrderItem { ItemName = item.Name, Price = item.Price, Order = order, ItemCategory = category }; orderItems.Add(t); } order.Items = orderItems; _orderManager.Create(order); }
private DateTime getDateVal(string key) { string val = _paramManager.GetValue(key); return(_timeManager.Parse(val, SystemDefaults.DefaultFormat)); }