public async Task <bool> CreateRace(RaceModel race) { return(await Task.Run(() => { race.Type = raceTypeDao.FindAll().FirstOrDefault(type => type.Type == race.Type.Type); race.Status = statusDao.FindAll().FirstOrDefault(status => status.Name == race.Status.Name); var created = raceDao.Insert(race.ToRace()); race.Id = created; return created > 0; })); }
public async Task <bool> SaveRace(RaceModel race) { return(await Task.Run(() => { race.Type = raceTypeDao.FindAll().FirstOrDefault(type => type.Type == race.Type.Type); race.Status = statusDao.FindAll().FirstOrDefault(status => status.Name == race.Status.Name); var saved = raceDao.Update(race.ToRace()); return saved; })); }