public Supplier Get(long id) { return(_suppliersRepository.Get(id)); }
public static void ChooseOperatioForSuppliersRepository(ISuppliersRepository suppliersRepository, OperationForSuppliersRepository suppliersRepositoryOperation) { switch (suppliersRepositoryOperation) { case OperationForSuppliersRepository.ShowAll: ShowAllSuppliers(suppliersRepository.Get()); break; case OperationForSuppliersRepository.ShowById: Console.WriteLine("Enter supplier Id: "); if (int.TryParse(Console.ReadLine(), out var supplierId)) { Console.WriteLine(suppliersRepository.Get(supplierId)); } break; case OperationForSuppliersRepository.Add: Supplier supplierToAdd = CreateSupplierToAdd(); suppliersRepository.Add(supplierToAdd); Console.WriteLine("New supplier added"); break; case OperationForSuppliersRepository.Update: Supplier supplierToUpdate = null; Console.Write("Enter supplier Id to update: "); if (int.TryParse(Console.ReadLine(), out var supplierIdToUpdate)) { supplierToUpdate = suppliersRepository.Get(supplierIdToUpdate); } Console.Write("Enter new Name: "); supplierToUpdate.Name = Console.ReadLine(); suppliersRepository.Update(supplierToUpdate); Console.WriteLine("Supplier updated"); break; case OperationForSuppliersRepository.Delete: Console.WriteLine("Enter supplier Id: "); if (int.TryParse(Console.ReadLine(), out var supplierIdToDelete)) { suppliersRepository.Delete(supplierIdToDelete); Console.WriteLine("Supplier deleted"); } break; case OperationForSuppliersRepository.GetSupplierInfoWithMaxQuantityOfGoods: var maxQuantityOfGoodsSupplier = suppliersRepository.GetSupplierInfoWithMaxQuantityOfGoods(); Console.WriteLine($"Supplier with max quantity of goods: {maxQuantityOfGoodsSupplier}"); break; case OperationForSuppliersRepository.GetSupplierInfoWithMinQuantityOfGoods: var minQuantityOfGoodsSupplier = suppliersRepository.GetSupplierInfoWithMaxQuantityOfGoods(); Console.WriteLine($"Supplier with max quantity of goods: {minQuantityOfGoodsSupplier}"); break; default: Environment.Exit(0); break; } }