public ActionResult ProcessMission(int id = 1) { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if ((HelperModel.CheckCDS(coll) == false)) //if not CDS { return(Redirect("/Home/Index")); } //--------------------------------------------------// Mission model = dal.GetMission(id); //string[] collId = new string[model.CollList.Count]; //int i = 0; //foreach (Collaborator c in dal.GetMission(id).CollList) //{ // collId[i++] = c.Id.ToString(); //} //ViewBag.Collablist = GetMultiCollaborators(collId); return(View(model)); }
// GET: Mission public ActionResult Index() { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if ((HelperModel.CheckCDS(coll) == false)) //if not CDS { return(Redirect("/Home/Index")); } //--------------------------------------------------// List <Mission> model = new List <Mission>(); foreach (Mission mi in dal.GetMissions()) { if (mi.ChiefId == coll.Id) { model.Add(mi); } } return(View(model)); }
public ActionResult ResetStatusMission(int id) { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if ((HelperModel.CheckCDS(coll) == false)) //if not CDS { return(Redirect("/Home/Index")); } //--------------------------------------------------// Mission m = dal.GetMission(id); if ((m.EndDate < DateTime.Now)) { m.Status = MissionStatus.COMPLETED; } else if ((m.StartDate < DateTime.Now) && (m.EndDate >= DateTime.Now)) { m.Status = MissionStatus.IN_PROGRESS; } else if ((m.StartDate > DateTime.Now) && (m.EndDate > DateTime.Now)) { m.Status = MissionStatus.PLANNED; } dal.SaveChanges(); return(Redirect("/Mission/Index")); }
public ActionResult Index() { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); //not in cds = cannot see if ((HelperModel.CheckCDS(coll) == false)) { return(Redirect("/Home/Index")); } //--------------------------------------------------// return(View(coll.Service)); }
[HttpPost] // Backend call of Index page public ActionResult CreateMission() { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if ((HelperModel.CheckCDS(coll) == false)) //if not CDS { return(Redirect("/Home/Index")); } //--------------------------------------------------// // Create the Mission int returnedId = dal.CreateMission(coll.Id); string redirectString = "/Mission/ProcessMission/?id=" + returnedId; //redirect to the right page, displaying the newly created Mission return(Redirect(redirectString)); }
public ActionResult CancelMission(int id) { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if ((HelperModel.CheckCDS(coll) == false)) //if not CDS { return(Redirect("/Home/Index")); } //--------------------------------------------------// Mission m = dal.GetMission(id); m.Status = MissionStatus.CANCELED; dal.SaveChanges(); return(Redirect("/Mission/Index")); }
public ActionResult ProcessList() { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); //not in management = cannot see if (!HelperModel.CheckManagement(coll) && !HelperModel.CheckCDS(coll)) { return(Redirect("/Home/Index")); } //--------------------------------------------------// List <Leave> LeaveListToBeReturnedAsModel = new List <Leave>(); List <Leave> allLeaves = dal.GetLeaves(); // for each Leave, check if they meet the following criterias // if yes, add them to the list returned to the View foreach (Leave e in allLeaves) { if (e.Collaborator != coll) // a coll cannot validate his own ER { // If the ER needs to be treated the classic way if (e.Treatment == HelperProcessing.CLASSIC) { if (HelperModel.CheckCDSRH(coll)) // CDS RH { if (e.Status == LeaveStatus.PENDING_APPROVAL_2) { LeaveListToBeReturnedAsModel.Add(e); } if (e.Status == LeaveStatus.PENDING_APPROVAL_1) { if (e.Collaborator.Service.GetChiefFromService() == coll.Id) { LeaveListToBeReturnedAsModel.Add(e); } } } else if (HelperModel.CheckRH(coll)) // RH { if (e.Status == LeaveStatus.PENDING_APPROVAL_2) { LeaveListToBeReturnedAsModel.Add(e); } } else if (HelperModel.CheckCDS(coll)) // CDS { if (e.Status == LeaveStatus.PENDING_APPROVAL_1) { // in order to know if the Chief needs to see the leave if (e.Collaborator.Service.GetChiefFromService() == coll.Id) { LeaveListToBeReturnedAsModel.Add(e); } } } } else { // The ER needs to be treated specifically if (e.Status == LeaveStatus.PENDING_APPROVAL_1) // please do not put pending2 in DAL for those leaves { switch (e.Treatment) { case HelperProcessing.DHR: if (HelperModel.CheckCDSRH(coll)) //si le coll traiteur est un CDSRH { LeaveListToBeReturnedAsModel.Add(e); } break; case HelperProcessing.HR: if (HelperModel.CheckRH(coll)) { LeaveListToBeReturnedAsModel.Add(e); } break; case HelperProcessing.CEO: if (HelperModel.CheckPDG(coll)) { LeaveListToBeReturnedAsModel.Add(e); } break; } } } } } return(View(LeaveListToBeReturnedAsModel)); }
[HttpPost] // Backend call of ProcessMission page public ActionResult ProcessMission(Mission model) { //------------Background identity check-------------// if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { return(Redirect("/Home/Index")); } Collaborator coll = dal.GetCollaborator(System.Web.HttpContext.Current.User.Identity.Name); if ((HelperModel.CheckCDS(coll) == false)) //if not CDS { return(Redirect("/Home/Index")); } //--------------------------------------------------// List <Collaborator> collList = new List <Collaborator>(); Mission m = dal.GetMission(model.Id); string selectedValues = Request.Form["right"]; if (selectedValues != null) { string[] selectedCollaboratorsId = selectedValues.Split(','); collList = new List <Collaborator>(); foreach (string i in selectedCollaboratorsId) { int.TryParse(i, out int collId); Collaborator c = dal.GetCollaborator(collId); collList.Add(c); if (!c.Missions.Contains(m)) { c.Missions.Add(m); } } } m.Name = model.Name; m.StartDate = model.StartDate; m.EndDate = model.EndDate; if ((m.EndDate < DateTime.Now) && (m.Status != MissionStatus.CANCELED)) { m.Status = MissionStatus.COMPLETED; } else if ((m.StartDate < DateTime.Now) && (m.EndDate >= DateTime.Now) && (m.Status != MissionStatus.CANCELED)) { m.Status = MissionStatus.IN_PROGRESS; } else if ((m.StartDate > DateTime.Now) && (m.EndDate > DateTime.Now) && (m.Status != MissionStatus.CANCELED)) { m.Status = MissionStatus.PLANNED; } else { m.Status = model.Status; } m.CollList.Clear(); m.CollList = collList; dal.SaveChanges(); return(Redirect("/Mission/Index")); }