Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            NewHire newHire = db.NewHires.Find(id);

            NewHireNotice newHireNotice = new NewHireNotice(newHire, "Cancel");

            if (TryValidateModel(newHireNotice) == true)
            {
                Mailer mailer = new Mailer(MessageTemplate.NewHireEmployee, true);

                if (newHire.IsContingent == true)
                {
                    mailer = new Mailer(MessageTemplate.NewHireContingent, true);
                }

                mailer.SetFromAddress(newHire.RequestersEmail);
                mailer.AddRecipient(newHire.ManagersEmail);
                mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject);

                db.NewHires.Remove(newHire);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("MailNotice", "Mail Notice Error");

            return(View());
        }
Example #2
0
        public ActionResult NewEmployee(NewHire employee)
        {
            employee.ValidateEmployee(ModelState, User);

            //if (db.NewHires.Any(x => x.WorkerID == employee.WorkerID))
            //{
            //    ModelState.AddModelError("Request", String.Format("{0} Already Requested", employee.HireType));
            //}

            if (ModelState.IsValid)
            {
                NewHireNotice newHireNotice = new NewHireNotice(employee, "New");

                if (TryValidateModel(newHireNotice) == true)
                {
                    if (employee.Suppress == false)
                    {
                        Mailer mailer = new Mailer(MessageTemplate.NewHireEmployee, true);

                        mailer.SetFromAddress(employee.RequestersEmail);
                        mailer.AddRecipient(employee.ManagersEmail);

                        if (employee.ITaaS == true)
                        {
                            mailer.AddITaaSNotificationGroup();
                        }

                        mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject);
                    }

                    db.NewHires.Add(employee);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("MailNotice", "Mail Notice Error");
            }

            ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct();
            ViewBag.Offices   = Office.GetOfficeNames(employee.Country, db);

            ViewBag.O365Profiles       = O365Profile.GetSelectList();
            ViewBag.O365ProfileDetails = PowerShell.GetHTMLString("NewHires", "O365ProfileDetails", null);

            return(View(employee));
        }
Example #3
0
        public ActionResult Edit(int id, NewHire newHire)
        {
            newHire.ValidateManager(ModelState);
            newHire.SetRequestersEmail(User);
            newHire.SetServiceDate();

            if (ModelState.IsValid)
            {
                NewHireNotice newHireNotice = new NewHireNotice(newHire, "Update");

                if (TryValidateModel(newHireNotice) == true)
                {
                    if (newHire.Suppress == false)
                    {
                        Mailer mailer = new Mailer(MessageTemplate.NewHireEmployee, true);

                        if (newHire.IsContingent == true)
                        {
                            mailer = new Mailer(MessageTemplate.NewHireContingent, true);
                        }

                        mailer.SetFromAddress(newHire.RequestersEmail);
                        mailer.AddRecipient(newHire.ManagersEmail);

                        if (newHire.ITaaS == true)
                        {
                            mailer.AddITaaSNotificationGroup();
                        }

                        mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject);
                    }

                    db.Entry(newHire).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("MailNotice", "Mail Notice Error");
            }

            ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct();
            ViewBag.Offices   = Office.GetOfficeNames(newHire.Country, db);

            return(View(newHire));
        }
Example #4
0
        public ActionResult NewContingent(NewHire contingent)
        {
            contingent.ValidateContingent(ModelState, User);

            if (db.NewHires.Any(x => x.FirstName == contingent.FirstName && x.LastName == contingent.LastName))
            {
                ModelState.AddModelError("Request", String.Format("{0} Already Requested", contingent.HireType));
            }

            if (ModelState.IsValid)
            {
                contingent.SetEmailAddress();

                NewHireNotice newHireNotice = new NewHireNotice(contingent, "New");

                if (TryValidateModel(newHireNotice) == true)
                {
                    Mailer mailer = new Mailer(MessageTemplate.NewHireContingent, true);

                    mailer.SetFromAddress(contingent.RequestersEmail);
                    mailer.AddRecipient(contingent.ManagersEmail);
                    mailer.SendMessage("NewHireNotice", newHireNotice, newHireNotice.Subject);

                    db.NewHires.Add(contingent);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("MailNotice", "Mail Notice Error");
            }

            ViewBag.Countries = db.Countries.Select(x => x.Name).Distinct();
            ViewBag.Offices   = Office.GetOfficeNames(contingent.Country, db);

            ViewBag.O365Profiles       = O365Profile.GetSelectList();
            ViewBag.O365ProfileDetails = PowerShell.GetHTMLString("NewHires", "O365ProfileDetails", null);

            return(View(contingent));
        }
Example #5
0
 public ActionResult NewHireNotice(NewHireNotice newHireNotice)
 {
     return(View(newHireNotice));
 }