public async Task <bool> InsertRoute(Entities.DTO.BaseRoute baseRoute)
        {
            var result = await _ctx.ExecuteStoredProcedureScalar <object>("USP_Insert_Route",
                                                                          "fromCode".WithValue(baseRoute.From),
                                                                          "toCode".WithValue(baseRoute.To),
                                                                          "price".WithValue(baseRoute.Price)
                                                                          );

            if (result == null || Convert.ToInt32(result) <= 0)
            {
                return(false);
            }

            return(true);
        }
        public async Task <IActionResult> NewRoute([FromBody] Entities.DTO.BaseRoute newRoute)
        {
            if (newRoute == null || string.IsNullOrEmpty(newRoute.From) ||
                string.IsNullOrEmpty(newRoute.To) || newRoute.Price <= 0)
            {
                return(BadRequest());
            }

            var result = await _service.InsertRoute(newRoute);

            if (result)
            {
                return(StatusCode(201));
            }

            return(BadRequest());
        }
Exemple #3
0
 public async Task <bool> InsertRoute(Entities.DTO.BaseRoute newRoute)
 {
     return(await _repo.InsertRoute(newRoute));
 }