示例#1
0
 private static void MapCommonParameters(ProjectsAddRequest model, SqlParameterCollection paramCollection)
 {
     paramCollection.AddWithValue("@ProjectName", model.ProjectName);
     paramCollection.AddWithValue("@Description", model.Description);
     paramCollection.AddWithValue("@Budget", model.Budget);
     paramCollection.AddWithValue("@Deadline", model.Deadline);
     paramCollection.AddWithValue("@CompanyId", model.CompanyId);
     paramCollection.AddWithValue("@UserIdCreated", UserService.GetCurrentUserId());
 }
示例#2
0
            public HttpResponseMessage Post(ProjectsAddRequest model)
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }
                ItemResponse <int> response = new ItemResponse <int>();

                response.Item = _projectService.Post(model);
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
示例#3
0
        public int Post(ProjectsAddRequest model)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Project_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                MapCommonParameters(model, paramCollection);

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

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


            return(id);
        }