public HttpResponseMessage Post(SkillAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = _skillService.Post(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public int Post(SkillAddRequest model) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.Skill_Insert", inputParamMapper : delegate(SqlParameterCollection paramCollection) { MapCommonParameters(model, paramCollection); SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int); p.Direction = ParameterDirection.Output; paramCollection.Add(p); }, returnParameters : delegate(SqlParameterCollection param) { Int32.TryParse(param["@Id"].Value.ToString(), out id); } ); return(id); }
private void MapCommonParameters(SkillAddRequest model, SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Name", model.Name); paramCollection.AddWithValue("@Code", model.Code); paramCollection.AddWithValue("@DisplayOrder", model.DisplayOrder); }