// GET: Project/Apply/5 public ActionResult Apply(int id) { int project_manager_id = int.Parse(Session["user_id"].ToString()); var req_found = db.pm_projectTeam.Where(team => team.project_id == id && team.member_id == project_manager_id).FirstOrDefault(); //return Content(req_found.ToString()); /*ViewBag.Msg = "5ra"; * ViewBag.req_found = req_found; * return RedirectToAction("Index"); */ if (req_found != null) { ViewBag.Msg = "You have sent request to joing this project, your request is still pending!"; //return Content(ViewBag); return(RedirectToAction("Index", ViewBag)); // return HttpNotFound(); } else { pm_projectTeam req = new pm_projectTeam(); req.member_id = project_manager_id; req.project_id = id; req.postion = 2; req.state = 0; db.pm_projectTeam.Add(req); db.SaveChanges(); ViewBag.Msg = "Request Sent successfully !"; return(RedirectToAction("Index", ViewBag)); } }
// GET: Project/Approve/5 public ActionResult Approve(int id) { pm_projectTeam team_member_request = db.pm_projectTeam.Find(id); //project id int project_id = int.Parse(team_member_request.project_id.ToString()); //project manager id int project_manager_id = int.Parse(team_member_request.member_id.ToString()); //update state team_member_request.state = 1; //delete other requests var requests = db.pm_projectTeam.Where(t => t.id != id); //remove other requests db.pm_projectTeam.RemoveRange(requests); //get project to change project manager id var approved_project = db.pm_project.Find(project_id); //update project manger id in project table approved_project.project_manger_id = project_manager_id; db.SaveChanges(); if (team_member_request == null) { return(HttpNotFound()); } return(RedirectToAction("Index")); }
public ActionResult InviteMemberSave(pm_projectTeam invitation) { //pm_projectTeam invitation = new pm_projectTeam(); ////return Content(project_id.ToString() + " " + member_id.ToString()); //invitation.member_id = member_id; //invitation.project_id = project_id; invitation.postion = 4; invitation.state = 0; db.pm_projectTeam.Add(invitation); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { try { pm_projectTeam invitation = db.pm_projectTeam.Find(id); db.pm_projectTeam.Remove(invitation); db.SaveChanges(); return(RedirectToAction("Index")); } catch { ViewBag.Msg = "Error while deleting!"; return(RedirectToAction("Index")); } }