Example #1
0
        public IActionResult DeleteConfirmed(int id)
        {
            var league = _leagueRepository.GetLeagueById(id);

            _leagueRepository.Delete(league);
            _leagueRepository.Save();
            return(RedirectToAction("Index"));
        }
        public void Handle(DeleteLeagueCommand command)
        {
            EnsureArg.IsNotNull(command);
            var commmandEntity = Mapper.Map <Domain.Entities.League>(command.LeagueModel);

            leagueRepository.Delete(commmandEntity);
            leagueRepository.SaveChanges();
        }
        public async Task <IActionResult> DeleteLeague(int id)
        {
            int loggedUserId;

            Int32.TryParse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value, out loggedUserId);

            var league = await leagueRepository.GetLeague(id);

            if (league.Admin.Id != loggedUserId)
            {
                return(BadRequest("You are not an admin of this league!"));
            }

            leagueRepository.Delete(league);

            if (await dataContext.Commit())
            {
                return(Ok());
            }

            return(BadRequest("Could not delete league"));
        }
Example #4
0
 /// <summary>
 /// Deletes the record matching the specified id.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns>true if successful</returns>
 public async Task <bool> Delete(Guid id)
 {
     return(await this.Handler.Execute(_log, async() => await _leagueRepository.Delete(id)));
 }
Example #5
0
 public async Task Delete(League League)
 {
     _Leagues.Delete(League);
     await _Leagues.Save();
 }