using SushiBarContracts.BindingModels; using SushiBarContracts.SearchModels; using SushiBarContracts.ViewModels; using SushiBarDatabaseImplement.Storages; namespace SushiBarBusinessLogic { public class CustomerLogic { private readonly CustomerStorage _customerStorage; public CustomerLogic(CustomerStorage CustomerStorage) { _customerStorage = CustomerStorage; } public List<CustomerViewModel>? ReadList(CustomerSearchModel? Model) { var List = Model is null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(Model); if (List is null) { return null; } return List; } public CustomerViewModel? ReadElement(CustomerSearchModel? Model) { if (Model is null) throw new ArgumentNullException(nameof(Model)); var Element = _customerStorage.GetElement(Model); if (Element is null) { return null; } return Element; } public bool Create(CustomerBindingModel Model) { if (_customerStorage.Insert(Model) is null) { return false; } return true; } public bool Update(CustomerBindingModel Model) { if (_customerStorage.Update(Model) is null) { return false; } return true; } public bool Delete(CustomerBindingModel Model) { if (_customerStorage.Delete(Model) is null) { return false; } return true; } } }