public bool Delete(Guid id) { try { return(_repository.Delete(id)); } catch (Exception ex) { _logger.LogError("Exception while deleting cities : {0} - {1} ", ex.StackTrace, ex.Message); throw ex; } }
public async Task <Result> Handle(DeleteAdCommand request, CancellationToken cancellationToken) { var ad = await adRepository.Find(request.Id, cancellationToken); if (ad == null) { return(false); } await adRepository.Delete(ad.Id, cancellationToken); return(Result.Success); }
public void Handle(DeleteAdCommand command) { var user = UserRepository.Get(command.UserId); Guard.IsNotNull(user, "user"); if (!user.UserRole.HasFlag(UserRole.Admin)) { throw new PowerException("权限不足"); } var ad = AdRepository.Get(command.Id); Guard.IsNotNull(ad, "ad"); AdRepository.Delete(ad); }
public async Task <ActionResult> Delete(int id, AdVM model) { try { if (!ModelState.IsValid) { return(View(model)); } var ad = await _adRepo.FindById(id); var isSuccess = await _adRepo.Delete(ad); if (!isSuccess) { ModelState.AddModelError("", "Something went wrong..."); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void Remove(int id) { _repository.Delete(_repository.Select(id)); }