public IHttpActionResult DeleteUser([FromBody] int id) { if (id <= 0) { return(BadRequest("Not a valid User id")); } var user = db.Users .Where(s => s.UserID == id) .FirstOrDefault(); db.Users.Remove(user); db.SaveChanges(); return(Ok()); }
public IHttpActionResult CreateProject(Project project) { Project prj = new Project(); prj.ProjectName = project.ProjectName; prj.StartDate = project.StartDate; prj.EndDate = project.EndDate; prj.Priority = project.Priority; db.Projects.Add(prj); db.SaveChanges(); if (project.managerId != null) { User UserData = db.Users.Where(x => x.UserID == project.managerId).FirstOrDefault(); UserData.ProjectID = prj.ProjectID; db.SaveChanges(); } return(Ok()); }
public IHttpActionResult DeleteTask([FromBody] int id) { if (id <= 0) { return(BadRequest("Not a valid User id")); } var task = db.Tasks .Where(s => s.TaskID == id) .FirstOrDefault(); db.Tasks.Remove(task); db.SaveChanges(); return(Ok()); }