public IHttpActionResult CreateTeam(FootballTeamModel team) { var mappedTeam = FootballTeamMapping.Map(team); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(_teamService.CreateTeam(mappedTeam))); }
public async Task <IActionResult> Create([FromBody] FootballTeamModel model) { var teamId = await _teamService.Create(model); Uri getDetailUri = new Uri(Url.AbsoluteAction("Get", "Team", new { id = teamId })); return(Created(getDetailUri, new { id = teamId.ToString("N") })); }
public Task Update(Guid id, FootballTeamModel model) { CheckExist(id); var teamEntity = _teamRepository.Get(x => x.Id == id).Single(); teamEntity.Coach = model.Coach; teamEntity.Country = model.Country; teamEntity.Name = model.Name; _teamRepository.Update(teamEntity, x => x.Coach, x => x.Country, x => x.Name); _unitOfWork.SaveChanges(); return(Task.CompletedTask); }
public async Task <Guid> Create(FootballTeamModel model) { var entity = new FootballTeamEntity() { Name = model.Name, Country = model.Country, Coach = model.Coach }; _teamRepository.Add(entity); await _unitOfWork.SaveChangesAsync(); return(entity.Id); }
public static FootballTeam Map(FootballTeamModel team) { var config = new DefaultMapConfig(); var result = config.ConvertUsing((FootballTeamModel source) => new FootballTeam() { TeamName = source.TeamName, WinsCount = source.WinsCount, LossesCount = source.LossesCount }); var team1 = ObjectMapperManager .DefaultInstance .GetMapper <FootballTeamModel, FootballTeam>(result) .Map(new FootballTeamModel() { TeamName = team.TeamName, WinsCount = team.WinsCount, LossesCount = team.LossesCount }); return(team1); }
public async Task <IActionResult> Update(Guid id, [FromBody] FootballTeamModel model) { await _teamService.Update(id, model); return(NoContent()); }