public ActionResult Create(Project newProject) { Project project = new Project(); project.TenantId = Auth.GetCurrentUser().TenantId; project.ManagerId = Auth.GetCurrentUser().UserId; project.Name = (!string.IsNullOrWhiteSpace(newProject.Name)) ? newProject.Name : "(Untitled Project)"; project.Start = (newProject.Start != null) ? newProject.Start : DateTime.Now.Date; project.ExpectedEnd = (newProject.ExpectedEnd != null) ? newProject.ExpectedEnd : DateTime.Now.AddMonths(1); project.Status = 1; //Check if the user put the start date after the end date, and swap if so if (project.Start.Value.CompareTo(project.ExpectedEnd.Value) > 0) { var start = project.Start; project.Start = project.ExpectedEnd; project.ExpectedEnd = start; } using (var db = new DataClassesDataContext()) { db.Projects.InsertOnSubmit(project); db.SubmitChanges(); } return RedirectToAction("Index"); }
public ProjectContext(Project project) { this.TenantId = project.TenantId; this.ProjectId = project.ProjectId; this.Name = project.Name.Trim(); this.RawDateStart = (DateTime)project.Start; this.RawDateEnd = (DateTime)project.ExpectedEnd; this.StatusId = project.Status; this.ManagerId = project.ManagerId; //Format date time in preferred output style this.Start = ((DateTime)(project.Start)).ToString("MM/dd/yyyy"); this.ExpectedEnd = ((DateTime)(project.ExpectedEnd)).ToString("MM/dd/yyyy"); this.Status = project.Status1.Name; this.Manager = project.User.Username; this.Requirements = new List<RequirementContext>(); foreach (var projReq in project.ProjectRequirements) { CurrentUserContext user = ProjectManager.Utils.Auth.GetCurrentUser(); if (user.IsManager || user.IsAdmin || user.UserId == projReq.Requirement.User.UserId) { Requirements.Add(new RequirementContext(projReq.Requirement)); } } }
public ActionResult GetProjectsJson() { var project = new Project(); return Json(new { projects = project.GetProjects(_db) }, JsonRequestBehavior.AllowGet); }
partial void DeleteProject(Project instance);
partial void UpdateProject(Project instance);
partial void InsertProject(Project instance);
private void detach_Projects(Project entity) { this.SendPropertyChanging(); entity.Tenant = null; }
private void attach_Projects(Project entity) { this.SendPropertyChanging(); entity.Tenant = this; }