Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        public async Task AddRouteDelayAsync(RouteDelay routeDelay)
        {
            await _context.RouteDelays.AddAsync(routeDelay);

            await _context.SaveChangesAsync();
        }
Esempio n. 4
0
 public async Task AddRouteDelayAsync(RouteDelay routeDelay)
 => await _repository.AddRouteDelayAsync(routeDelay);