// GET: SuppliersController1/Delete/5 public ActionResult Delete(int id) { var leavetype = _repos.FindById(id); var isSucess = _repos.Delete(leavetype); if (!isSucess) { return(BadRequest()); } return(RedirectToAction(nameof(Index))); }
///<Summary> ///Delete ///This method deletes one Suppliers record from the store ///</Summary> ///<returns> ///void ///</returns> ///<parameters> /// ///</parameters> public virtual void Delete() { Doing(this); IDAOSuppliers daoSuppliers = _iSuppliersRepository.New(); RegisterDataObject(_iSuppliersRepository, _iSuppliersRepository.BaseData(daoSuppliers)); BeginTransaction(_iSuppliersRepository, "deleteBOSuppliers"); try { daoSuppliers.İd = _id; _iSuppliersRepository.Delete(daoSuppliers); CommitTransaction(_iSuppliersRepository); Done(this); } catch (Exception ex) { Failed(this, ex); RollbackTransaction(_iSuppliersRepository, "deleteBOSuppliers"); Handle(this, ex); } }
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; } }