public HttpResponseMessage EchoClassModule(ModuleAddRequest model)
 {
     if (ModelState.IsValid)
     {
         return Request.CreateResponse(HttpStatusCode.OK, model);
     }
     else
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
     }
 }
示例#2
0
        public int InsertModule(ModuleAddRequest model)
        {
            int ModulesId = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Modules_Insert_v2"
               , inputParamMapper: delegate (SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@ModuleName", model.ModuleName);
                   //paramCollection.AddWithValue("@Length", model.Length);
                   //paramCollection.AddWithValue("@Labs", model.Labs);
                   //paramCollection.AddWithValue("@RequiredReading", model.RequiredReading);
                   //paramCollection.AddWithValue("@Homework", model.Homework);
                   //paramCollection.AddWithValue("@Description", model.Description);
                   paramCollection.AddWithValue("@SectionId", model.SectionId);

                   SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                   p.Direction = System.Data.ParameterDirection.Output;

                   paramCollection.Add(p);
               },
               returnParameters: delegate (SqlParameterCollection param)
               {
                   int.TryParse(param["@Id"].Value.ToString(), out ModulesId);
               });

            return ModulesId;
        }