public ActionResult NewProject(int customerId) { Project newProject = new Project(); newProject.CustomerId = customerId; newProject.Name = "Nytt Projekt"; newProject.Customer = customerRepository.Customers.FirstOrDefault(c => c.Id == customerId); ProjectViewModel newProjectModel = new ProjectViewModel(); newProjectModel.Users = userRepository.Users; newProjectModel.Project = newProject; return PartialView(newProjectModel); }
public ActionResult ProjectDetails(int? projectId) { Project selectedProject = new Project(); ProjectViewModel projectModel = new ProjectViewModel(); projectModel.Users = userRepository.Users; if(projectId != null){ selectedProject = repository.Projects.FirstOrDefault(p => p.Id == projectId); projectModel.DebHours = (from r in selectedProject.Report select r.Deb).Sum() ?? 0; projectModel.EjDebHours = (from r in selectedProject.Report select r.EjDeb).Sum() ?? 0; projectModel.TotalHours = projectModel.EjDebHours + projectModel.DebHours; } projectModel.Project = selectedProject; return PartialView(projectModel); }
public void SaveProject(Project project) { if (project.Id == 0) { context.Projects.Add(project); } else { Project dbProject = context.Projects.Find(project.Id); if (dbProject != null) { dbProject.Name = project.Name; dbProject.Active = project.Active; dbProject.Description = project.Description; dbProject.FastBtn = project.FastBtn; dbProject.KontoStr = project.KontoStr; dbProject.Referens = project.Referens; dbProject.UserId = project.UserId; } } context.SaveChanges(); }