コード例 #1
0
        public async Task <bool> DeleteAsync(Watchlist item)
        {
            bool result = _repository.Remove(item);

            if (result)
            {
                await _repository.UnitOfWork.SaveChangesAsync();

                return(result);
            }
            else
            {
                throw new NotFoundException(ErrorCode.MarketNotFount, "Watchlist not found");
            }
        }
コード例 #2
0
        public IActionResult Remove(int id)
        {
            var watchlist = _watchlistRepository.GetWatchlist(id);

            _watchlistRepository.Remove(watchlist);

            _clientNotification
            .AddSweetNotification("Success", "Pet has been removed from watchlist", NotificationType.success);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #3
0
        public IActionResult Remove(int Id)
        {
            if (Id == 0)
            {
                return(Content("Invalid request"));
            }

            try{
                _repository.Remove(_repository.GetWatchlist(Id));
                return(RedirectToAction(nameof(Index)));
            } catch (Exception ex) {
                throw ex;
            }
        }