Example #1
0
 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;
     }
 }
Example #2
0
            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);
            }
Example #3
0
        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());
            }
        }
Example #5
0
 public void Remove(int id)
 {
     _repository.Delete(_repository.Select(id));
 }