Ejemplo n.º 1
0
        public int Create(FormAddRequest model)
        {
            int id = 0;

            this._dataProvider.ExecuteNonQuery(
                "Form_Insert",
                inputParamMapper : delegate(SqlParameterCollection paramList)
            {
                SqlParameter param  = new SqlParameter();
                param.ParameterName = "@Id";
                param.SqlDbType     = SqlDbType.Int;
                param.Direction     = ParameterDirection.Output;
                paramList.Add(param);

                paramList.AddWithValue("@Title", model.Title);
                paramList.AddWithValue("@Description", model.Description);
                paramList.AddWithValue("@Version", model.Version);
                paramList.AddWithValue("@ModifiedBy", model.ModifiedBy);
            },
                returnParameters : delegate(SqlParameterCollection paramList)
            {
                id = (int)paramList["@Id"].Value;
            });
            return(id);
        }
Ejemplo n.º 2
0
 public HttpResponseMessage Create(FormAddRequest model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             int id = _formService.Create(model);
             ItemResponse <int> resp = new ItemResponse <int>();
             resp.Item = id;
             log.Info("Create Form");
             return(Request.CreateResponse(HttpStatusCode.OK, resp));
         }
         else
         {
             log.Error("Error: Model State Invalid");
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         log.Error("Error: Create Form Failed", ex);
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }