Esempio n. 1
0
        public ActionResult NewEmployeeLookup(string workerId, string hireType)
        {
            ViewBag.WorkerIDHelp       = PowerShell.GetHTMLString("NewHires", "WorkerIDHelp", null);
            ViewBag.HireTypeGuidelines = PowerShell.GetHTMLString("NewHires", "HireTypeGuidelines", null);

            if (String.IsNullOrWhiteSpace(workerId))
            {
                ModelState.AddModelError("WorkerID", "Worker ID Required");
                return(View(NewHire.EmployeeHireTypes()));
            }

            NewHire employee = NewHire.EmployeeLookup(workerId, hireType, db);

            if (employee == null)
            {
                ModelState.AddModelError("WorkerID", "Workday Lookup Error");
                return(View(NewHire.EmployeeHireTypes()));
            }

            if (employee.EmailAddress == null)
            {
                employee.SetEmailAddress();
            }

            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("NewEmployee", employee));
        }
Esempio n. 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));
        }
Esempio n. 3
0
        public ActionResult NewContingent()
        {
            NewHire contingent = NewHire.Contingent();

            if (contingent == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            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));
        }
Esempio n. 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));
        }