Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #4
0
        public void Import(Dictionary <string, ImportExportRecord> people, O365Service service)
        {
            foreach (var person in people)
            {
                if (string.IsNullOrEmpty(person.Value.PhotoLocation))
                {
                    // no photo .. skipping
                    Logger.Debug($"No photo found for {person.Value.Upn} ... skipping");
                    continue;
                }

                using (var fs = File.Open(person.Value.PhotoLocation, FileMode.Open))
                {
                    var profile = new O365Profile(new UpnIdentifier(person.Value.Upn));
                    _o365.UpdateUserProfilePhoto(profile, service, fs);

                    Logger.Info($"Uploaded photo for {person.Value.Upn}");
                }
            }
        }
Пример #5
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));
        }
Пример #6
0
        public ActionResult O365ProfileDetails()
        {
            List <O365Profile> o365Profiles = O365Profile.GetProfileList();

            return(PartialView("_O365ProfileDetails", o365Profiles));
        }