예제 #1
0
 public async Task <IActionResult> Create([FromBody] MatchVMRequest MatchVM)
 {
     try
     {
         Match m = MatchVM.ToModel();
         return(this.Ok(await MatchAPI.Add(m)));
     }
     catch
     {
         return(StatusCode(500));
     }
 }
예제 #2
0
        public async Task <IActionResult> Update(int Id, [FromBody] MatchVMRequest MatchVM)
        {
            try
            {
                Match m = await this.MatchAPI.GetById(Id);

                m = MatchVM.ToModel(m);
                return(this.Ok(await MatchAPI.Update(m)));
            }
            catch
            {
                return(StatusCode(500));
            }
        }
예제 #3
0
 public static Match ToModel(this MatchVMRequest vm, Match m = null)
 {
     if (m == null)
     {
         m = new Match();
     }
     m.Name            = vm.Name;
     m.Date            = vm.Date;
     m.IdHomeManager   = vm.HomeManager;
     m.IdAwayManager   = vm.AwayManager;
     m.MatchPlayerAway = vm.AwayPlayers.ToModelAway(m.Id);
     m.MatchPlayerHome = vm.HomePlayers.ToModelHome(m.Id);
     m.Idreferee       = vm.Referee;
     return(m);
 }