/// <summary> /// Gönderilen Entityi veritabanından siler. Eğer save parametresi false olarak gönderilirse bu işlemden sonra verinin veritabanından silinebilmesi için Save() yapılması gerekir. /// </summary> /// <param name="entity"></param> /// <param name="save"></param> public virtual void Delete(T entity, bool save = true) { try { _repository.Delete(entity); if (save) { _unitOfWork.Save(); } } catch (Exception e) { throw e; } }
public void When_Delete_Shop_Then_Shop_Are_Removed() { using (var context = new ShopsContext(ContextOptions)) { //Arrange var repository = new Repository.Repository(_mapper, context); var shopRequest = new ShopRequest() { Name = "Carrefour" }; var item = repository.Insert(shopRequest); //Act repository.Delete(item.Id); item = repository.GetShop(item.Id); //Assert Assert.IsNull(item); } }
public Employee DeleteEmployee(Employee employee) { if (employee == null) { throw new NullReferenceException("Employee object cannot be null."); } if (employee.Id < 1) { throw new ArgumentException("Employee ID is not defined for deletion."); } var delEmp = _repository.GetBy(p => p.Id == employee.Id).FirstOrDefault(); if (delEmp != null) { _repository.Delete(delEmp); _repository.SaveAll(); } return(delEmp); }
public ActionResult Delete(int id) { rep.Delete(rep.Get(id)); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
public void Delete(int categoryID) { repository.Delete("Categories", categoryID); }
public void Delete(int supplierID) { repository.Delete("Suppliers", supplierID); }
public void Delete(int productsID) { repository.Delete("Products", productsID); }