public async Task <bool> PostRouteDelay(RouteDelay routeDelay) { var json = JsonConvert.SerializeObject(routeDelay); var result = await _httpClient.PostAsync(Uri + "reports/delay", AddMediaTypeHeaderValueToJson(json)); return(result.StatusCode.Equals(HttpStatusCode.Created)); }
public async Task <IActionResult> PostRouteDelay(RouteDelay routeDelay) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _service.AddRouteDelayAsync(routeDelay); } catch (SqlException ex) { return(BadRequest(ex.Message)); } return(StatusCode(StatusCodes.Status201Created)); }
public async Task AddRouteDelayAsync(RouteDelay routeDelay) { await _context.RouteDelays.AddAsync(routeDelay); await _context.SaveChangesAsync(); }
public async Task AddRouteDelayAsync(RouteDelay routeDelay) => await _repository.AddRouteDelayAsync(routeDelay);