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 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); }