public OrderIsValidToImportValidator( DomainModelValidatorBaseSpecifications <Order> domainModelValidatorBaseSpecifications, OrderSpecifications orderSpecifications, IOrderItemIsValidToImportValidator orderItemIsValidToImportValidator, IOrderShippingIsValidToImportValidator orderShippingIsValidToImportValidator, IOrderStatusIsValidToImportValidator orderStatusIsValidToImportValidator ) : base(domainModelValidatorBaseSpecifications) { AddSpecificationsForTenantInfo(); AddSpecificationsForCreationInfo(); AddSpecificationsForActivationInfo(); AddSpecification(orderSpecifications.OrderMustHaveCodeSpecification); AddSpecification(orderSpecifications.OrderMustHaveCodeWithValidLengthSpecification); AddSpecification(orderSpecifications.OrderMustHaveCustomerSpecification); AddSpecification(orderSpecifications.OrderMustHaveItemSpecification); AddSpecification(orderSpecifications.OrderMustHaveShippingSpecification); AddSpecification(orderSpecifications.OrderMustHaveStatusSpecification); AddSpecification(orderSpecifications.OrderMustHaveValidDateSpecification); AddSpecification(orderSpecifications.OrderMustHaveValidItemSequencesSpecification); _orderItemIsValidToImportValidator = orderItemIsValidToImportValidator; _orderShippingIsValidToImportValidator = orderShippingIsValidToImportValidator; _orderStatusIsValidToImportValidator = orderStatusIsValidToImportValidator; }
public Dictionary <string, string> saveOrder([FromBody] OrderSpecifications json) { bool check = true; bool check2 = true; //Convert.ToDateTime(json.OrderDateTime) DB_A1AEE5_essShoppingCart db = new DB_A1AEE5_essShoppingCart(); Order order = new Order(); //order.ID = Guid.NewGuid(); order.Amount = json.Amount; order.CustomerId = json.CustomerId; order.OrderDateTime = Convert.ToDateTime(json.OrderDateTime); order.ConfirmedDateTime = Convert.ToDateTime(json.ConfirmedDateTime); order.Status = json.Status; order.PaymentRefID = json.PaymentRefID; order.FirstName = json.FirstName; order.LastName = json.LastName; order.Phone = json.Phone; order.Email = json.Email; order.Zipcode = json.Zipcode; order.City = json.City; order.DeliveryAddress = json.DeliveryAdress; order.PayerID = json.PayerID; order.Notes = json.Notes; order.AppliedDiscount = json.AppliedDiscount; order.PayBy = json.PayBy; order.DeliveryTime = TimeSpan.Parse(json.DeliveryTime); order.PayWith = json.PayWith; order.OrderStatus = json.OrderStatus; order.DeliveryMintues = TimeSpan.Parse(json.DeliveryMinutes); Dictionary <string, string> dictionary = new Dictionary <string, string>(); db.Orders.Add(order); try { db.SaveChanges(); check = true; } catch (Exception e) { check = false; dictionary.Add("result", "Order Not Created"); } if (check == true) { foreach (var item in json.OrderDetail) { OrderDetails orderDetails = new OrderDetails(); orderDetails.OderID = order.ID; orderDetails.Price = item.ODPrice; orderDetails.ProductID = item.ODProductID; orderDetails.Quantity = item.ODQuantity; orderDetails.ProductExtraID = item.ODProductExtraID; orderDetails.ProductExtraPrice = item.ODProductExtraPrice; db.OrderDetails.Add(orderDetails); try { db.SaveChanges(); check2 = true; } catch (Exception e) { check2 = false; } } } if (check2 == true && check != false) { dictionary.Add("result", "Order Created"); } else if (check2 == false && check != false) { dictionary.Add("result", "Order Not Created"); } return(dictionary); }
public IEnumerable <Order> FindAllActiveOrders() { return(_base.FindAll(OrderSpecifications.ActiveOrder())); }