public async Task UpdateRider(DTO.Rider rider) { Models.Rider current = await GetRider(rider.IdRider); RiderMapper.MapRiderDTO(current, rider); await deliveriesDbContext.SaveChangesAsync(); }
internal static void MapRiderDTO(Models.Rider current, DTO.Rider input) { current.Active = input.Active.HasValue ? input.Active.Value : current.Active; current.AverageRating = input.AverageRating ?? current.AverageRating; current.Range = input.Range ?? current.Range; current.RiderName = string.IsNullOrEmpty(input.RiderName) ? current.RiderName : input.RiderName; current.StartingPoint = GetGeometry(input.StartingPoint) ?? current.StartingPoint; }
public async Task <int> AddRider(DTO.Rider rider) { Models.Rider newRider = RiderMapper.MapNewRiderDTO(rider); deliveriesDbContext.Rider.Add(newRider); await deliveriesDbContext.SaveChangesAsync(); return(newRider.IdRider); }
internal static Models.Rider MapNewRiderDTO(DTO.Rider input) { Models.Rider output = new Models.Rider() { Active = true, AverageRating = null, Range = input.Range, RiderName = input.RiderName, StartingPoint = GetGeometry(input.StartingPoint) }; return(output); }