public IActionResult BusStop([FromBody] BusStopBindingModel busStopBindingModel) { if (!ModelState.IsValid) { return(BadRequest(new ApiError(ModelState))); } busService.AddBusStop(busStopBindingModel); return(Ok()); }
public void AddBusStop(BusStopBindingModel busStopBindingModel) { int cityId = 0; if (double.Parse(busStopBindingModel.Longitude) > 27) { cityId = 1; } else { cityId = 2; } BusStop busStop = mapper.Map <BusStop>(busStopBindingModel); busStop.CityId = cityId; Context.BusStops.Add(busStop); Context.SaveChanges(); }