public bool TryChangeOrderStatusBySeller(Order order, OrderStatus status, out ICollection <string> errors) { errors = new List <string>(); //check order null if (order == null) { errors.Add("Order can not be empty"); return(false); } //check product operating model OperatingModelService modelService = modelServiceFactory .GetService(sellerRepository.GetProductBy(order.SellerId, order.ProductTypeId).Model); if (!modelService.CanSellerManagesOrder()) { errors.Add("You don't have right to manage this order"); } //check order status if (order.Status == OrderStatus.Confirming) { errors.Add("Can not change an order which are waiting for confirmation"); } if (!errors.Any()) { order.Status = status; return(true); } return(false); }
public bool TryChangeOperatingModel(int sellerId, int productTypeId, OperatingModel model, out ICollection <string> errors) { errors = new List <string>(); //check product null Product product = sellerRepository.GetProductBy(sellerId, productTypeId); if (product == null) { errors.Add("Could not found product"); return(false); } OperatingModelService recentModelService = modelServiceFactory.GetService(product.Model); OperatingModelService alternativeModelService = modelServiceFactory.GetService(model); if (!recentModelService.CanLeaveThisModel(product, out errors)) { return(false); } if (!alternativeModelService.CanChangeToThisModel(product, out errors)) { return(false); } else { product.Model = model; return(true); } }
public bool TryRejectOrderBySeller(Order order, out ICollection <string> errors) { errors = new List <string>(); //check order null if (order == null) { errors.Add("Order can not be empty"); return(false); } //check product operating model OperatingModelService modelService = modelServiceFactory .GetService(sellerRepository.GetProductBy(order.SellerId, order.ProductTypeId).Model); if (!modelService.CanSellerRejectsOrder()) { errors.Add("You don't have right to reject this order"); } //check order status if (order.Status != OrderStatus.Confirming) { errors.Add("Can only reject an order while firming it"); } if (!errors.Any()) { order.Seller.RejectOrder(order); return(true); } return(false); }
public bool TryUnregister(int sellerId, int productTypeId, out ICollection <string> errors) { errors = new List <string>(); //check product existence Product product = sellerRepository.GetProductBy(sellerId, productTypeId); if (product == null) { errors.Add("Could not found product"); return(false); } //check if can leave this product operating model OperatingModelService modelService = modelServiceFactory.GetService(product.Model); if (modelService.CanLeaveThisModel(product, out errors)) { product.Seller.UnregisterProduct(product); return(true); } return(false); }