public Order.Domain.Model.Order AddAsync(Order.Domain.Model.Order order) { var entity = _context.Orders.Add(order).Entity; _context.SaveChanges(); return(entity); }
public bool IsSatisfied(Order.Domain.Model.Order order) { if (order.Category == CategoryTypes.Category.Book.ToString()) { Console.WriteLine("Duplicate packing slip for the royalty department has been sent and generated a commission payment to the agent.."); } return(true); }
/// <summary> /// This method will check for all available business rules in system. /// </summary> /// <param name="order"></param> private void EvaluateforAllBusinessRules(Order.Domain.Model.Order order) { if (order.Category == "Book" || order.Category == "PhysicalProduct" || order.Category == "Membership" || order.Category == "MembershipUpgrade" || order.Category == "VideoProduct") { var rule = RuleHelper.And( new IRule[5] { new BookProductRule(), new PhysicalProductRule(), new VideoProductRule(), new MembershipProductRule(), new UpgradeMembershipRule() }); _ruleService.Evaluate(rule, order); } }
/// <summary> /// Order processing method add order in DB /// </summary> /// <param name="id"></param> /// <param name="userId"></param> /// <param name="category"></param> /// <param name="name"></param> /// <param name="description"></param> /// <param name="createdAt"></param> /// <returns></returns> public Order.Domain.Model.Order AddOrder(Guid id, Guid userId, Guid category, string name, string description, DateTime createdAt) { var productDetail = _productRepository.Get(id); var categoryDetail = _categoryRepository.Get(category); if (productDetail == null || categoryDetail == null) { throw new Exception("product or category_not_found"); } var order = new Order.Domain.Model.Order(name, productDetail.Name, categoryDetail.Name); EvaluateforAllBusinessRules(order); return(_orderRepository.AddAsync(order)); }