public int UrunSil(Urun urun) { try { _repo.Delete(urun); _unit.Save(); return(1); } catch (Exception) { return(0); } }
public IActionResult UrunSil(int id) { Urun entity = urunRepo.GetbyId(id); if (entity != null) { Account acc = new Account("naimmobilya", "742112311237693", "nqeO8i7tnQpNPnSAQyESOqImU-I"); Cloudinary cloudinary = new Cloudinary(acc); List <UrunImage> images = imageRepo.GetByUrunId(entity.UrunId).ToList(); foreach (var item in images) { cloudinary.DeleteResources(item.UrunImageId.ToString()); } urunRepo.Delete(entity); TempData["message"] = $"{entity.UrunId} id li ürün silindi"; } return(RedirectToAction("UrunList")); }
public async Task <UrunResponse> DeleteAsync(int id) { try { var urun = await urunRepository.GetByIdUrun(id); if (urun == null) { return(new UrunResponse("Urun bulunamadı.")); } else { await urunRepository.Delete(id); unitOfWork.CompleteAsync(); return(new UrunResponse(urun)); } } catch (Exception ex) { return(new UrunResponse($"Urun silinirken bir hata oluştu : {ex.Message}")); } }