/// <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;
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public ActionResult Delete(int id)
 {
     rep.Delete(rep.Get(id));
     return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK));
 }
Exemplo n.º 5
0
 public void Delete(int categoryID)
 {
     repository.Delete("Categories", categoryID);
 }
Exemplo n.º 6
0
 public void Delete(int supplierID)
 {
     repository.Delete("Suppliers", supplierID);
 }
Exemplo n.º 7
0
 public void Delete(int productsID)
 {
     repository.Delete("Products", productsID);
 }