public void Delete(Project project) { var projectToRemove = Projects.FirstOrDefault(p => p.id == project.id); if (projectToRemove != null) { Projects.Remove(projectToRemove); } }
public void Save(Project project) { if (project.id <= 0) { project.id = Projects.Any() ? Projects.Max(p => p.id) + 1 : 1; } if (Projects.Any() && Projects.Any(p => p.id == project.id)) { Projects.First(p => p.id == project.id).projectName = project.projectName; } else { Projects.Add(project); } }
public ActionResult Update(Project project) { projectRepository.Save(project); return Json(project); }