コード例 #1
0
        public IActionResult DeleteConfirmed(int id)
        {
            var league = _leagueRepository.GetLeagueById(id);

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

            leagueRepository.Delete(commmandEntity);
            leagueRepository.SaveChanges();
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
ファイル: LeagueService.cs プロジェクト: Brendon-Coombes/dihl
 /// <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)));
 }
コード例 #5
0
 public async Task Delete(League League)
 {
     _Leagues.Delete(League);
     await _Leagues.Save();
 }