private static void MapCommonProjectParameters(ProjectAddRequest model, SqlCommand cmd) { cmd.Parameters.AddWithValue("@Title", model.Title); cmd.Parameters.AddWithValue("@Logline", model.Logline ?? String.Empty); cmd.Parameters.AddWithValue("@StoryTypeId", model.StoryTypeId); cmd.Parameters.AddWithValue("@Notes", model.Notes ?? String.Empty); if (model.StoryTypeId == 6) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(Plot)); DataTable table = new DataTable(); foreach (PropertyDescriptor prop in properties) { table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType); } foreach (Plot item in model.Plots) { DataRow row = table.NewRow(); foreach (PropertyDescriptor prop in properties) { row[prop.Name] = prop.GetValue(item) ?? DBNull.Value; } table.Rows.Add(row); } cmd.Parameters.AddWithValue("@List", table); } }
public bool Add(ProjectAddRequest project) { try { return(_projectRepository.Add(project)); } catch (Exception ex) { throw ex; } }
public IActionResult Add([FromBody] ProjectAddRequest project) { try { return(Ok(_projectService.Add(project))); } catch (Exception ex) { message = ex.Message; _log.LogError(message); return(StatusCode(StatusCodes.Status500InternalServerError, message)); } }
public HttpResponseMessage Insert(ProjectAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); if (model.AutoStructured) { response.Item = ProjectService.InsertStructured(model); } else { response.Item = ProjectService.Insert(model); } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public bool Add(ProjectAddRequest addProject) { try { SqlConnection sqlconn = new SqlConnection(connectionString); SqlCommand sqlComm = new SqlCommand("newProject"); sqlconn.Open(); sqlComm.Connection = sqlconn; sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.AddWithValue("@project", addProject.Name); sqlComm.ExecuteNonQuery(); sqlconn.Close(); return(true); } catch (Exception ex) { throw ex; } }
public static int Insert(ProjectAddRequest model) { int id = 0; using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "dbo.Project_Insert"; if (model.StoryTypeId == 6) { model.Plots = new List <Plot>(); Plot pA = new Plot(); pA.PlotName = "A"; model.Plots.Add(pA); Plot pB = new Plot(); pB.PlotName = "B"; model.Plots.Add(pB); Plot pC = new Plot(); pC.PlotName = "C"; model.Plots.Add(pC); } MapCommonProjectParameters(model, cmd); cmd.Parameters.AddWithValue("@AspNetUserId", _getId()); SqlParameter outputId = new SqlParameter("@Id", System.Data.SqlDbType.Int) { Direction = System.Data.ParameterDirection.Output }; cmd.Parameters.Add(outputId); cmd.ExecuteNonQuery(); id = (int)outputId.Value; } conn.Close(); } return(id); }
/// <summary> /// 新增项目 /// </summary> public ProjectAddResponse AddProject(ProjectAddRequest request) { ProjectAddResponse response = new ProjectAddResponse(); Model.ProjectInfo info = new Model.ProjectInfo() { ProjectNumber = request.ProjectNumber, ProjectName = request.ProjectName, ProjectDescribe = request.ProjectDescribe, ProjectStaffId = request.ProjectStaffId, TechStaffId = request.TechStaffId, ProductStaffId = request.ProductStaffId, TestStaffId = request.TestStaffId, MarketStaffId = request.MarketStaffId, ProjectStage = request.ProjectStage, ProjectStartTime = request.ProjectStartTime, ProjectOutTime = request.ProjectOutTime, ProjectStaus = 1 }; var result = dal.AddProject(info); if (result > 0) { response.Message = "新增项目成功"; response.IsRegistSuccess = true; } else { response.Message = "新增项目失败"; response.IsRegistSuccess = false; } return(response); }
/// <summary> /// 新增项目 /// </summary> public ProjectAddResponse AddProject(ProjectAddRequest request) { return(ApiRequestHelp.Post <ProjectAddRequest, ProjectAddResponse>(request)); }
/// <summary> /// 新增项目 /// </summary> public JsonResult AddProject(ProjectAddRequest request) { return(Json(bll.AddProject(request))); }
/// <summary> /// 新增项目 /// </summary> public ProjectAddResponse AddProject(ProjectAddRequest request) { return(ProjectBll.Instance.AddProject(request)); }