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