Ejemplo n.º 1
0
 public HttpResponseMessage Insert(TruckingCompaniesAddRequest model)
 {
     try
     {
         int id = _truckingCompaniesService.Insert(model);
         return(Request.CreateResponse(HttpStatusCode.OK, id));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
        public int Insert(TruckingCompaniesAddRequest model)
        {
            int id = 0;

            Adapter.ExecuteQuery("dbo.TruckingCompanies_Insert", new[]
            {
                SqlDbParameter.Instance.BuildParameter("@TruckingCompanyName", model.TruckingCompanyName, System.Data.SqlDbType.NVarChar, 50),
                SqlDbParameter.Instance.BuildParameter("@Location", model.Location, System.Data.SqlDbType.NVarChar, 50),
                SqlDbParameter.Instance.BuildParameter("@Id", 0, System.Data.SqlDbType.Int, paramDirection: System.Data.ParameterDirection.Output)
            },
                                 (parameters =>
            {
                id = parameters.GetParamValue <int>("@Id");
            }));

            return(id);
        }