public async Task <IActionResult> Create(MatchScheduleCreateBindingModel matchScheduleCreateBindingModel) { MatchScheduleServiceModel matchScheduleServiceModel = matchScheduleCreateBindingModel.To <MatchScheduleServiceModel>(); await this.matchScheduleService.CreateMatchSchedule(matchScheduleServiceModel); return(this.Redirect("/")); }
public async Task <bool> CreateMatchSchedule(MatchScheduleServiceModel matchScheduleServiceModel) { MatchSchedule matchSchedule = matchScheduleServiceModel.To <MatchSchedule>(); matchSchedule.MatchStatus.Name = GlobalConstants.MatchStatusActive; this.context.MatchSchedules.Add(matchSchedule); int result = await this.context.SaveChangesAsync(); return(result > 0); }
public async Task <IActionResult> Edit(string id, MatchScheduleEditBindingModel matchScheduleEditBindingModel) { if (!this.ModelState.IsValid) { throw new ArgumentException(); } MatchScheduleServiceModel matchScheduleServiceModel = matchScheduleEditBindingModel.To <MatchScheduleServiceModel>(); await this.matchScheduleService.EditMatchSchedule(id, matchScheduleServiceModel); return(this.Redirect($"/MatchSchedule/All")); }
public async Task <MatchScheduleServiceModel> GetById(string id) { var gameFromDb = await this.context.MatchSchedules.SingleOrDefaultAsync(game => game.Id == id); MatchScheduleServiceModel match = new MatchScheduleServiceModel { Id = gameFromDb.Id, HomeTeam = gameFromDb.HomeTeam, GuestTeam = gameFromDb.GuestTeam, HomeTeamScore = 0, GuestTeamScore = 0, MatchDate = gameFromDb.MatchDate, }; return(match); }
public async Task <bool> EditMatchSchedule(string id, MatchScheduleServiceModel matchScheduleServiceModel) { MatchSchedule gameFromDb = await this.context.MatchSchedules.SingleOrDefaultAsync(game => game.Id == id); if (gameFromDb == null) { throw new ArgumentNullException(nameof(gameFromDb)); } gameFromDb.HomeTeam = matchScheduleServiceModel.HomeTeam; gameFromDb.GuestTeam = matchScheduleServiceModel.GuestTeam; gameFromDb.MatchDate = matchScheduleServiceModel.MatchDate; gameFromDb.HomeTeamScore = matchScheduleServiceModel.HomeTeamScore; gameFromDb.GuestTeamScore = matchScheduleServiceModel.GuestTeamScore; this.context.Update(gameFromDb); int result = await this.context.SaveChangesAsync(); return(result > 0); }