예제 #1
0
        public ActionResult <Athlete> AddAthlete(Athlete athlete)
        {
            Athlete obj;

            if (athlete.IdAthlete != 0)
            {
                obj = athleteService.Update(athlete);
                if (obj == null)
                {
                    return(NoContent());
                }
            }
            else
            {
                var possibleExist = athleteService.GetByEmail(athlete.Email);
                if (possibleExist == null)
                {
                    obj = athleteService.Add(athlete);
                }
                else
                {
                    return(Conflict());
                }
            }

            return(Ok(obj));
        }
예제 #2
0
 public IActionResult Save(Athlete athlete)
 {
     if (athlete.Id >= 1)
     {
         _athleteService.Update(athlete);
     }
     else
     {
         _athleteService.Add(athlete);
     }
     return(Ok(_athleteService.SaveAll()));
 }