protected void OdsProject_Details_Inserted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e) { int result = Convert.ToInt32(e.ReturnValue, System.Globalization.CultureInfo.CurrentCulture.NumberFormat); if (result != 0) { Project project = new ProjectBLL().GetProjectByProjectID(result); UserBLL userBLL = new UserBLL(); Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name); if (user != null) { // ProjectInfo TextBox txtProjectName = (TextBox)formViewProject.FindControl("txtProjectName"); TextBox txtClient = (TextBox)formViewProject.FindControl("txtClient"); TextBox txtAddress1 = (TextBox)formViewProject.FindControl("txtAddress1"); TextBox txtAddress2 = (TextBox)formViewProject.FindControl("txtAddress2"); DropDownList ddlCity = (DropDownList)formViewProject.FindControl("ddlCity"); TextBox txtState = (TextBox)formViewProject.FindControl("txtState"); TextBox txtZipCode = (TextBox)formViewProject.FindControl("txtZipCode"); TextBox txtDescription = (TextBox)formViewProject.FindControl("txtDescription"); TextBox txtComments = (TextBox)formViewProject.FindControl("txtComments"); ProjectInfo projectInfo = new ProjectInfo(); projectInfo.ProjectName = txtProjectName.Text; projectInfo.Client = txtClient.Text; projectInfo.Address1 = txtAddress1.Text; projectInfo.Address2 = txtAddress2.Text; projectInfo.CityID = Convert.ToInt32(ddlCity.SelectedValue); projectInfo.State = txtState.Text; projectInfo.ZipCode = txtZipCode.Text.Replace("-", ""); projectInfo.Description = txtDescription.Text.Substring(0, Math.Min(txtDescription.Text.Length, 5000)); projectInfo.Comments = txtComments.Text.Substring(0, Math.Min(txtComments.Text.Length, 5000)); projectInfo.ProjectID = project.ProjectID; projectInfo.ProjectReference.EntityKey = project.EntityKey; new ProjectInfoBLL().CreateNewProjectInfo(projectInfo); // // Group_Projects List <Group> groupList = user.Group_Users.Select(instance => instance.Group).ToList(); Group group = groupList[0]; Group_Projects group_Projects = new Eisk.BusinessEntities.Group_Projects(); group_Projects.GroupID = group.GroupID; group_Projects.GroupReference.EntityKey = group.EntityKey; group_Projects.ProjectID = project.ProjectID; group_Projects.ProjectReference.EntityKey = project.EntityKey; new Group_ProjectsBLL().CreateNewGroup_Projects(group_Projects); // } Response.RedirectToRoute("project-details", new { edit_mode = "edit", Project_id = result.ToString() }); } }
public Project CreteProject(string projectName, User user, City city, List <Group> groups) { Project project = new Project(); project.CreatorUserID = user.UserID; project.CreatedDate = DateTime.Now; project.EditorUserID = user.UserID; project.EditedDate = DateTime.Now; new ProjectBLL().CreateNewProject(project); ProjectInfo projectInfo = new ProjectInfo(); projectInfo.ProjectName = projectName; projectInfo.CityID = city.CityID; projectInfo.CityReference.EntityKey = city.EntityKey; projectInfo.ProjectID = project.ProjectID; projectInfo.ProjectReference.EntityKey = project.EntityKey; new ProjectInfoBLL().CreateNewProjectInfo(projectInfo); // // Group_Projects Group group = groups.First(); Group_Projects group_Projects = new Eisk.BusinessEntities.Group_Projects(); group_Projects.GroupID = group.GroupID; group_Projects.GroupReference.EntityKey = group.EntityKey; group_Projects.ProjectID = project.ProjectID; group_Projects.ProjectReference.EntityKey = project.EntityKey; new Group_ProjectsBLL().CreateNewGroup_Projects(group_Projects); // return(project); }
public object Post([FromBody] ProjectModel newProject) { User user = (User)HttpContext.Current.Items["user"]; City city = (City)HttpContext.Current.Items["city"]; List <Group> groups = (List <Group>)HttpContext.Current.Items["groups"]; Project project = new Project(); project.CreatedDate = DateTime.Now; project.CreatorUserID = user.UserID; project.EditedDate = DateTime.Now; project.EditorUserID = user.UserID; new ProjectBLL().CreateNewProject(project); ProjectInfo projectInfo = new ProjectInfo(); projectInfo.ProjectName = newProject.ProjectName; projectInfo.Client = newProject.Client; projectInfo.Address1 = newProject.Address1; projectInfo.Address2 = newProject.Address2; projectInfo.CityID = newProject.CityID; projectInfo.CityReference.EntityKey = city.EntityKey; projectInfo.State = newProject.State; projectInfo.ZipCode = newProject.ZipCode != null?newProject.ZipCode.Replace("-", "") : ""; projectInfo.Description = newProject.Description != null?newProject.Description.Substring(0, Math.Min(newProject.Description.Length, 5000)) : ""; projectInfo.Comments = newProject.Comments != null?newProject.Comments.Substring(0, Math.Min(newProject.Comments.Length, 5000)) : ""; projectInfo.ProjectID = project.ProjectID; projectInfo.ProjectReference.EntityKey = project.EntityKey; new ProjectInfoBLL().CreateNewProjectInfo(projectInfo); ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocation(); projectInfoTreeLocation.Acres = newProject.Acres; projectInfoTreeLocation.DistanceBetweenTrees = newProject.DistanceBetweenTrees; projectInfoTreeLocation.Lots1 = newProject.Lots; projectInfoTreeLocation.Parkings = newProject.Parkings; if ((newProject.Lat == null || newProject.Lat == 0) || (newProject.Lon == null || newProject.Lon == 0)) { newProject.Lat = city.Lat; newProject.Lon = city.Lon; } projectInfoTreeLocation.Lat = newProject.Lat; projectInfoTreeLocation.Lon = newProject.Lon; Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(projectInfoTreeLocation.Lon.ToString(), projectInfoTreeLocation.Lat.ToString(), @"~/Javascript/"); projectInfoTreeLocation.X = Convert.ToDecimal(anewpointObj["x"]); projectInfoTreeLocation.Y = Convert.ToDecimal(anewpointObj["y"]); projectInfoTreeLocation.ProjectID = project.ProjectID; projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey; new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation); // Group_Projects Group group = groups[0]; Group_Projects group_Projects = new Eisk.BusinessEntities.Group_Projects(); group_Projects.GroupID = group.GroupID; group_Projects.GroupReference.EntityKey = group.EntityKey; group_Projects.ProjectID = project.ProjectID; group_Projects.ProjectReference.EntityKey = project.EntityKey; new Group_ProjectsBLL().CreateNewGroup_Projects(group_Projects); // // Project project = new ProjectBLL().CreateNewProject(newProject.ProjectName, user, city, groups); return(ProjectModel.GetProjectObject(project)); }