Esempio n. 1
0
        public IActionResult Index(StaffProfile p)
        {
            if (p != null)
            {
                StaffProfile profile = profileRepo.GetStaffProfileByID(p.StaffProfileID);
                profile.FirstName          = p.FirstName;
                profile.LastName           = p.LastName;
                profile.EmailNotifications = p.EmailNotifications;

                int verify = profileRepo.UpdateStaff(profile);
                if (verify == 1)
                {
                    //TODO add feedback of success
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    //TODO add feedback for error
                }
            }
            else
            {
                ModelState.AddModelError("", "User Not Found");
            }
            return(View(p));
        }
Esempio n. 2
0
        public IActionResult StaffEdit(StaffProfile sp)
        {
            if (sp != null)
            {
                StaffProfile staff = staffRepo.GetStaffProfileByID(sp.StaffProfileID);
                staff.Email     = sp.Email;
                staff.FirstName = sp.FirstName;
                staff.LastName  = sp.LastName;
                staff.Role      = sp.Role;

                int verify = staffRepo.UpdateStaff(staff);
                if (verify == 1)
                {
                    //TODO add feedback of success
                    return(RedirectToAction("Staff"));
                }
                else
                {
                    //TODO add feedback for error
                }
            }
            else
            {
                ModelState.AddModelError("", "Staff Not Found");
            }
            return(View(sp));
        }
Esempio n. 3
0
        public async Task <IActionResult> AddStaff(AdminVM vm)
        {
            StaffUser user = new StaffUser {
                UserName = vm.NewStaff.Email
            };
            IdentityResult result = await userManager.CreateAsync(user, vm.Password);

            if (result.Succeeded)
            {
                await userManager.AddToRoleAsync(user, vm.NewStaff.Role);
            }
            ;

            StaffProfile profile = new StaffProfile
            {
                FirstName          = vm.NewStaff.FirstName,
                LastName           = vm.NewStaff.LastName,
                Email              = vm.NewStaff.Email,
                EmailNotifications = vm.NewStaff.EmailNotifications,
                User = user,
                Role = vm.NewStaff.Role
            };

            staffRepo.AddStaff(profile);

            return(RedirectToAction("Staff"));
        }
Esempio n. 4
0
 public StaffDTO()
 {
     Department   = new DepartmentDTO();
     Subject      = new DepartmentDTO();
     Position     = new PositionDTO();
     StaffProfile = new StaffProfile();
 }
Esempio n. 5
0
        public IActionResult AddKWTask(KWTaskVM vm, int?staffProfileID, string returnURL)
        {
            var kwtask = new KWTask
            {
                Message     = vm.NewKWTask.Message,
                AlertDate   = vm.NewKWTask.AlertDate,
                DateCreated = vm.NewKWTask.DateCreated,
                DateDue     = vm.NewKWTask.DateDue,
                Priority    = vm.NewKWTask.Priority
            };

            if (kwtask.AlertDate == null)
            {
                kwtask.Type = "Task";
            }
            else
            {
                kwtask.Type = "Alert";
            }

            if (staffProfileID != null)
            {
                StaffProfile staff = staffRepo.GetStaffProfileByID((int)staffProfileID);
                staff.Tasks.Add(kwtask);
            }

            taskRepo.AddKWTask(kwtask);

            //TODO: See if there is a way to just close the modal and not refresh the page
            return(Redirect(returnURL));
        }
        private string getStaffMail(StaffProfile staffProfile)
        {
            if (staffProfile == null)
            {
                return(null);
            }

            var preferredMail = staffProfile.StaffProfileElectronicMails.FirstOrDefault(x => x.PrimaryEmailAddressIndicator.HasValue && x.PrimaryEmailAddressIndicator.Value);

            var mail = preferredMail ?? staffProfile.StaffProfileElectronicMails.FirstOrDefault();

            return(mail?.ElectronicMailAddress);
        }
        private string getStaffTelephone(StaffProfile staffProfile)
        {
            if (staffProfile == null)
            {
                return(null);
            }

            var preferredTelephone = staffProfile.StaffProfileTelephones.FirstOrDefault(x => x.PrimaryMethodOfContact.HasValue && x.PrimaryMethodOfContact.Value);

            var telephone = preferredTelephone ?? staffProfile.StaffProfileTelephones.FirstOrDefault();

            return(telephone?.TelephoneNumber);
        }
        private string getStaffSMSDomain(StaffProfile staffProfile)
        {
            if (staffProfile == null)
            {
                return(null);
            }

            var preferredTelephone = staffProfile.StaffProfileTelephones.FirstOrDefault(x => x.PrimaryMethodOfContact.HasValue && x.PrimaryMethodOfContact.Value);

            var telephone = preferredTelephone ?? staffProfile.StaffProfileTelephones.FirstOrDefault();

            return(telephone?.TextMessageCarrierType?.SmsSuffixDomain);
        }
Esempio n. 9
0
        public static void LoadContent()
        {
            GameModeManager.LoadGameModes();
            Logger.Debug("Loaded game modes.");

            FontManager.LoadFonts();

            Screen.TextBox.TextFont = FontManager.GetFontContainer("textfont");
            Logger.Debug("Loaded fonts.");

            TextureManager.InitializeTextures();
            MusicManager.LoadMusic();
            SoundEffectManager.LoadSounds(false);
            Logger.Debug("Loaded content.");

            Logger.Debug("Validated files. Result: " + Security.FileValidation.IsValid(true));
            if (!Security.FileValidation.IsValid(false))
            {
                Logger.Log(Logger.LogTypes.Warning, "Core.vb: File Validation failed! Download a fresh copy of the game to fix this issue.");
            }

            GameMessage = new GameMessage(TextureManager.DefaultTexture, new System.Drawing.Size(10, 40), new Vector2(0, 0))
            {
                Dock            = GameMessage.DockStyles.Top,
                BackgroundColor = Color.Black,
                TextPosition    = new Vector2(10, 10)
            };
            Logger.Debug("Gamemessage initialized.");

            GameOptions = Options.LoadOptions();

            var p0 = Path.Combine(GameController.GamePath + "Temp");

            if (Directory.Exists(p0))
            {
                try
                {
                    Directory.Delete(p0, true);
                    Logger.Log(Logger.LogTypes.Message, "Core.vb: Deleted Temp directory.");
                }
                catch (Exception) { Logger.Log(Logger.LogTypes.Warning, "Core.vb: Failed to delete the Temp directory."); }
            }

            StaffProfile.SetupStaff();

            //ScriptVersion2.ScriptLibrary.InitializeLibrary();
        }
Esempio n. 10
0
        public IActionResult SendPasswordResetLink(int id)
        {
            StaffProfile profile = profileRepo.GetStaffProfileByID(id);
            StaffUser    user    = userManager.
                                   FindByNameAsync(profile.User.UserName).Result;

            if (user == null)
            {
                return(View("Index"));
            }

            var token = userManager.
                        GeneratePasswordResetTokenAsync(user).Result;

            var resetLink = Url.Action("ResetPassword",
                                       "Auth", new { token = token },
                                       protocol: HttpContext.Request.Scheme);

            var email = new MimeMessage();

            email.From.Add(new MailboxAddress("KWFCI", "*****@*****.**"));
            email.Subject = "Password Reset";
            email.Body    = new TextPart("plain")
            {
                Text = "Click the link to reset your password " + resetLink
            };
            email.To.Add(new MailboxAddress(user.UserName));

            using (var client = new SmtpClient())
            {
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                client.Connect("smtp.gmail.com", 587, false);

                client.AuthenticationMechanisms.Remove("XOAUTH2");
                client.Authenticate("kwfamilycheckin", "Fancy123!");

                client.Send(email);
                client.Disconnect(true);
            }

            //TODO: Pop up Alert box saying the reset link has been sent to their email
            return(RedirectToAction("Index", profile));
        }
Esempio n. 11
0
        //[Route("Index")]
        public IActionResult AllKWTasks(string filter)
        {
            /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/
            Helper.GetToday();

            var criticalVB = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList();

            foreach (KWTask task in taskRepo.GetAllTasksByType("Task").Where(t => t.Priority == 5).ToList())
            {
                criticalVB.Add(task);
            }

            ViewBag.Critical = criticalVB;

            ViewBag.Filter = filter;
            var vm = new KWTaskVM();

            vm.StaffList = staffRepo.GetAllStaffProfiles().ToList();
            var KWTasks = taskRepo.GetAllKWTasks().Where(t => t.Type != "Onboarding").ToList();

            foreach (KWTask t in KWTasks.ToList())
            {
                if (t.Priority == 5)
                {
                    StaffProfile profile = staffRepo.GetProfileByTask(t);
                    if (profile != null)
                    {
                        profile.Tasks.Remove(t);
                        staffRepo.UpdateStaff(profile);
                    }
                }
                foreach (StaffProfile s in vm.StaffList)
                {
                    if (s.Tasks.Contains(t))
                    {
                        t.StaffName  = s.FirstName + " " + s.LastName;
                        t.StaffEmail = s.Email;
                    }
                }
            }
            vm.KWTasks   = KWTasks;
            vm.NewKWTask = new KWTask();
            return(View(vm));
        }
Esempio n. 12
0
        public async Task <IActionResult> StaffDelete(int id)
        {
            StaffProfile profile = staffRepo.GetStaffProfileByID(id);

            if (profile != null)
            {
                StaffUser user = await userManager.FindByNameAsync(profile.Email);

                await userManager.DeleteAsync(user);

                staffRepo.DeleteStaff(profile);
                return(RedirectToAction("Staff"));
            }
            else
            {
                ModelState.AddModelError("", "Staff Not Found");
            }
            return(RedirectToAction("Home"));
        }
        private StaffProfile UserProfileModelToStaffProfile(string staffUniqueId, UserProfileModel model)
        {
            var staffProfile = new StaffProfile
            {
                StaffUniqueId = staffUniqueId,
                FirstName     = model.FirstName,
                MiddleName    = model.MiddleName,
                LastSurname   = model.LastSurname,
                NickName      = model.Nickname,
                PreferredMethodOfContactTypeId = model.PreferredMethodOfContactTypeId,
                ReplyExpectations           = model.ReplyExpectations,
                LanguageCode                = model.LanguageCode,
                StaffProfileElectronicMails = model.ElectronicMails.Select(x => new StaffProfileElectronicMail
                {
                    StaffUniqueId                = staffUniqueId,
                    ElectronicMailTypeId         = x.ElectronicMailTypeId,
                    ElectronicMailAddress        = x.ElectronicMailAddress,
                    PrimaryEmailAddressIndicator = x.PrimaryEmailAddressIndicator
                }).ToList(),
                StaffProfileTelephones = model.TelephoneNumbers.Select(x => new StaffProfileTelephone
                {
                    StaffUniqueId                  = staffUniqueId,
                    TelephoneNumberTypeId          = x.TelephoneNumberTypeId,
                    TelephoneNumber                = x.TelephoneNumber,
                    TextMessageCapabilityIndicator = x.TextMessageCapabilityIndicator,
                    PrimaryMethodOfContact         = x.PrimaryMethodOfContact,
                    TelephoneCarrierTypeId         = x.TelephoneCarrierTypeId,
                }).ToList(),
                StaffProfileAddresses = model.Addresses.Select(x => new StaffProfileAddress
                {
                    StaffUniqueId            = staffUniqueId,
                    AddressTypeId            = x.AddressTypeId,
                    StreetNumberName         = x.StreetNumberName,
                    ApartmentRoomSuiteNumber = x.ApartmentRoomSuiteNumber,
                    City = x.City,
                    StateAbbreviationTypeId = x.StateAbbreviationTypeId,
                    PostalCode   = x.PostalCode,
                    NameOfCounty = x.NameOfCounty,
                }).ToList(),
            };

            return(staffProfile);
        }
Esempio n. 14
0
        //First unassigns the task from staff, then assigns it, then updates the repo
        private bool ProcessAssign(KWTask t, List <StaffProfile> sps, StaffProfile staff)
        {
            foreach (StaffProfile sp in sps)
            {
                if (sp.Tasks.Contains(t))
                {
                    sp.Tasks.Remove(t);
                }
            }
            staff.Tasks.Add(t);
            int verify = staffRepo.UpdateStaff(staff);

            if (verify > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 15
0
        public static void AddAdministrator(DbEntities db, string Name, string ICNo, string Email, string MobileNo)
        {
            var user = db.User.Local.Where(r => r.Email == Email).FirstOrDefault() ?? db.User.Where(r => r.Email == Email).FirstOrDefault();

            if (user == null)
            {
                var useraccount = new UserAccount
                {
                    LoginId      = Email,
                    IsEnable     = true,
                    LoginAttempt = 0,
                    HashPassword = "******",
                    Salt         = "/ZCqmg=="
                };

                var staff = new StaffProfile
                {
                    BranchId      = null,
                    DepartmentId  = null,
                    DesignationId = null
                };

                db.User.Add(
                    new User
                {
                    Name         = Name,
                    ICNo         = ICNo,
                    Email        = Email,
                    MobileNo     = MobileNo,
                    UserType     = UserType.Staff,
                    Display      = true,
                    CreatedDate  = DateTime.Now,
                    UserAccount  = useraccount,
                    StaffProfile = staff
                });
            }
        }
Esempio n. 16
0
        public void LoginFunction()
        {
            string username  = txtUsername.Text;
            string password  = txtPassword.Text;
            string AuditInfo = "Logged into the System";

            if (username != "" && password != "")
            {
                if (rdoAdmin.Checked == true)
                {
                    int UserType = 1;
                    int auth     = obj.Admin_Auth(username, password, UserType);
                    try
                    {
                        if (auth == 1)
                        {
                            ap = new AdminPanel();
                            SetValueForText1 = txtUsername.Text;
                            UserTypeLogin    = 1;
                            EmpID            = sb.GetEmpID(username);
                            Ab.InsertAudit(SetValueForText1, AuditInfo);
                            ap.Show();
                            Hide();
                        }
                        else
                        {
                            switch (MessageBox.Show("Authentication Failed? try again",
                                                    "Login Failed",
                                                    MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Question))
                            {
                            case DialogResult.Yes:
                                this.Hide();
                                LoginForm form = new LoginForm();
                                form.Show();
                                break;

                            case DialogResult.No:
                                Application.Exit();
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                else if (rdoManager.Checked == true)
                {
                    int UserType = 2;
                    int auth     = obj.Manager_Auth(username, password, UserType);
                    try
                    {
                        if (auth == 1)
                        {
                            Management_Profile mp = new Management_Profile();
                            SetValueForText1 = txtUsername.Text;
                            UserTypeLogin    = 2;
                            EmpID            = sb.GetEmpID(username);
                            Ab.InsertAudit(SetValueForText1, AuditInfo);
                            mp.Show();
                            Hide();
                        }
                        else
                        {
                            switch (MessageBox.Show("Authentication Failed? try again",
                                                    "Login Failed",
                                                    MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Question))
                            {
                            case DialogResult.Yes:
                                this.Hide();
                                LoginForm form = new LoginForm();
                                form.Show();
                                break;

                            case DialogResult.No:
                                Application.Exit();
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (rdoStaff.Checked == true)
                {
                    int UserType = 3;
                    int auth     = obj.Staff_Auth(username, password, UserType);
                    try
                    {
                        if (auth == 1)
                        {
                            sp = new StaffProfile();
                            SetValueForText1 = txtUsername.Text;
                            EmpID            = sb.GetEmpID(username);
                            UserTypeLogin    = 3;
                            Ab.InsertAudit(SetValueForText1, AuditInfo);
                            sp.Show();
                            Hide();
                        }
                        else
                        {
                            switch (MessageBox.Show("Authentication Failed? try again",
                                                    "Login Failed",
                                                    MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Question))
                            {
                            case DialogResult.Yes:
                                Hide();
                                LoginForm form = new LoginForm();
                                form.Show();
                                break;

                            case DialogResult.No:
                                Application.Exit();
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }

            else
            {
                try
                {
                    switch (MessageBox.Show("Username &/or Password cannot be Empty",
                                            "Login Failed",
                                            MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question))
                    {
                    case DialogResult.Yes:
                        Hide();
                        LoginForm form = new LoginForm();
                        form.Show();
                        break;

                    case DialogResult.No:
                        Application.Exit();
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 17
0
        public async Task <IActionResult> Index()
        {
            /*Login Logic*/
            StaffUser user = await userManager.FindByNameAsync(User.Identity.Name);

            Helper.StaffUserLoggedIn    = user;
            Helper.StaffProfileLoggedIn = Helper.DetermineProfile(staffProfRepo);
            /*End Login Logic*/

            /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/
            Helper.GetToday();

            /* Priority reassignment Logic */
            var tasks = taskRepo.GetAllKWTasks().Where(t => t.Type != "Onboarding");


            foreach (KWTask t in tasks.ToList())
            {
                int diff = (int)(t.DateDue - DateTime.Today).Value.TotalDays;
                if (diff < 0 && t.Priority < 5)
                {
                    StaffProfile profile = staffProfRepo.GetProfileByTask(t);

                    t.Priority = 5;
                    taskRepo.UpdateKWTask(t);

                    if (profile != null)
                    {
                        profile.Tasks.Remove(t);
                        staffProfRepo.UpdateStaff(profile);
                    }
                }
                else if (diff == 0 && t.Priority < 4)
                {
                    t.Priority = 4;
                    taskRepo.UpdateKWTask(t);
                }

                else if (diff <= 2 && t.Priority < 3)
                {
                    t.Priority = 3;
                    taskRepo.UpdateKWTask(t);
                }

                else if (diff == 3 && t.Priority < 2)
                {
                    t.Priority = 2;
                    taskRepo.UpdateKWTask(t);
                }
            }



            /*Display Alerts Logic*/
            ViewBag.Name   = Helper.StaffProfileLoggedIn.FirstName;
            ViewBag.Alerts = Helper.StaffProfileLoggedIn.Tasks.Where(
                t => t.Type == "Alert" &&
                (DateTime.Compare(DateTime.Now, t.AlertDate.GetValueOrDefault()) == 0 ||
                 DateTime.Compare(DateTime.Now, t.AlertDate.GetValueOrDefault()) > 0)).ToList();

            var criticalVB = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList();

            foreach (KWTask task in taskRepo.GetAllTasksByType("Task").Where(t => t.Priority == 5).ToList())
            {
                criticalVB.Add(task);
            }

            ViewBag.Critical = criticalVB;

            /*End Display Alerts Logic*/

            /*Populate ViewModel Logic*/
            var vm = new HomeVM();

            /*TODO Be aware this directly queries the database, may break if StaffProfile or KWTask models change*/
            string sqlGlobal   = "SELECT * FROM dbo.KWTasks WHERE StaffProfileID IS NULL";
            string sqlPersonal = "SELECT * FROM dbo.KWTasks WHERE StaffProfileID = " + Helper.StaffProfileLoggedIn.StaffProfileID;

            vm.GlobalTasks   = taskRepo.GetTasksFromSQL(sqlGlobal).Where(t => t.Type != "Onboarding").ToList();
            vm.PersonalTasks = taskRepo.GetTasksFromSQL(sqlPersonal).Where(t => t.Type != "Onboarding").ToList();

            List <Broker> brokers = new List <Broker>();

            foreach (Interaction i in Helper.StaffProfileLoggedIn.Interactions)
            {
                foreach (Broker b in brokerRepo.GetAllBrokers())
                {
                    if (b.Interactions.Contains(i))
                    {
                        i.BrokerName = b.FirstName + " " + b.LastName;

                        if (!brokers.Contains(b))
                        {
                            brokers.Add(b);
                        }
                    }
                }
            }
            ViewBag.Brokers = brokers;


            vm.PersonalInteractions = Helper.StaffProfileLoggedIn.Interactions;
            vm.NewTask    = new KWTask();
            vm.NewBroker  = new Broker();
            vm.NewMessage = new Message();
            vm.StaffList  = staffProfRepo.GetAllStaffProfiles().ToList();
            /*End Populate ViewModel Logic*/

            return(View(vm));
        }
Esempio n. 18
0
 public int UpdateStaff(StaffProfile staff)
 {
     context.StaffProfiles.Update(staff);
     return(context.SaveChanges());
 }
Esempio n. 19
0
 public int DeleteStaff(StaffProfile staff)
 {
     context.StaffProfiles.Remove(staff);
     return(context.SaveChanges());
 }
Esempio n. 20
0
 public int AddStaff(StaffProfile staff)
 {
     context.StaffProfiles.Add(staff);
     return(context.SaveChanges());
 }
Esempio n. 21
0
        public ActionResult Create(StaffViewModel staff)
        {
            string fileName = Path.GetFileNameWithoutExtension(staff.ProfileImage.FileName);

            string extension = Path.GetExtension(staff.ProfileImage.FileName);

            fileName       = fileName + DateTime.Now.ToString("yymmssff") + extension;
            staff.imageUrl = fileName;
            staff.ProfileImage.SaveAs(Path.Combine(Server.MapPath("~/images/staff"), fileName));

            var depname = _context.Departments.Where(d => d.Id == staff.DepartmentId).Select(d => d.DepartmentName).SingleOrDefault();

            var stf = new StaffProfile
            {
                DepName                          = depname,
                DepartmentId                     = staff.DepartmentId,
                FirstName                        = staff.FirstName,
                SecondName                       = staff.SecondName,
                LastName                         = staff.LastName,
                imageUrl                         = staff.imageUrl,
                Email                            = staff.Email,
                Gender                           = staff.Gender,
                Nationality                      = staff.Nationality,
                Specialization                   = staff.Specialization,
                Status                           = staff.Status,
                LinkdenLink                      = staff.LinkdenLink,
                Office                           = staff.Office,
                PersonalStatement                = staff.PersonalStatement,
                WorkHistory                      = staff.WorkHistory,
                AcademicRank                     = staff.AcademicRank,
                EducationalBackground            = staff.EducationalBackground,
                ContributionToScienceAndResearch = staff.ContributionToScienceAndResearch,
                AdditionalResponsibility         = staff.AdditionalResponsibility
            };

            if (staff.Id == 0)
            {
                _context.StaffProfiles.Add(stf);
            }
            else
            {
                var staffInDb = _context.StaffProfiles.Single(s => s.Id == staff.Id);


                staffInDb.FirstName                        = staff.FirstName;
                staffInDb.SecondName                       = staff.SecondName;
                staffInDb.LastName                         = staff.LastName;
                staffInDb.Office                           = staff.Office;
                staffInDb.Email                            = staff.Email;
                staffInDb.DepName                          = depname;
                staffInDb.DepartmentId                     = staff.DepartmentId;
                staffInDb.AcademicRank                     = staff.AcademicRank;
                staffInDb.AdditionalResponsibility         = staff.AdditionalResponsibility;
                staffInDb.ContributionToScienceAndResearch = staff.ContributionToScienceAndResearch;
                staffInDb.Status                           = staff.Status;
                staffInDb.WorkHistory                      = staff.WorkHistory;
                staffInDb.Specialization                   = staff.Specialization;
                staffInDb.PersonalStatement                = staff.PersonalStatement;
                staffInDb.imageUrl                         = staff.imageUrl;
                staffInDb.LinkdenLink                      = staff.LinkdenLink;
                staffInDb.Nationality                      = staff.Nationality;
                staffInDb.EducationalBackground            = staff.EducationalBackground;
                staffInDb.Gender                           = staff.Gender;
            }



            _context.SaveChanges();
            //}



            //return Json(new { success = true, message = "successfully Submitted" }, JsonRequestBehavior.AllowGet);
            return(RedirectToAction("Index"));
        }
Esempio n. 22
0
        public static async void EnsurePopulated(IApplicationBuilder app)
        {
            ApplicationDbContext       context     = app.ApplicationServices.GetRequiredService <ApplicationDbContext>();
            UserManager <StaffUser>    userManager = app.ApplicationServices.GetRequiredService <UserManager <StaffUser> >();
            RoleManager <IdentityRole> roleManager = app.ApplicationServices.GetRequiredService <RoleManager <IdentityRole> >();

            string firstName = "Bob";
            string lastName  = "Loblaw";
            string email     = "*****@*****.**";
            bool   notify    = true;
            string role      = "Staff";
            string password  = "******";

            //Create Identity User before StaffProfile, so you can add to the profile
            //Populates staff members
            if (!context.StaffProfiles.Any())
            {
                StaffUser user = await userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    user = new StaffUser {
                        UserName = email
                    };
                    IdentityResult result = await userManager.CreateAsync(user, password);

                    if (await roleManager.FindByNameAsync(role) == null)
                    {
                        await roleManager.CreateAsync(new IdentityRole("Staff"));

                        if (result.Succeeded)
                        {
                            await userManager.AddToRoleAsync(user, role);
                        }
                    }
                }

                StaffProfile profile = new StaffProfile
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    Email              = email,
                    EmailNotifications = notify,
                    User = user,
                    Role = role
                };

                context.StaffProfiles.Add(profile);

                firstName = "Nicole";
                lastName  = "Wedertz";
                email     = "*****@*****.**";
                notify    = true;
                role      = "Staff";
                password  = "******";

                //Create Identity User before StaffProfile, so you can add to the profile
                //Populates staff members

                user = await userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    user = new StaffUser {
                        UserName = email
                    };
                    IdentityResult result = await userManager.CreateAsync(user, password);

                    if (await roleManager.FindByNameAsync(role) == null)
                    {
                        await roleManager.CreateAsync(new IdentityRole("Staff"));

                        if (result.Succeeded)
                        {
                            await userManager.AddToRoleAsync(user, role);
                        }
                    }
                }

                profile = new StaffProfile
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    Email              = email,
                    EmailNotifications = notify,
                    User = user,
                    Role = role
                };

                context.StaffProfiles.Add(profile);

                firstName = "Tom";
                lastName  = "Dye";
                email     = "*****@*****.**";
                notify    = true;
                role      = "Staff";
                password  = "******";

                //Create Identity User before StaffProfile, so you can add to the profile
                //Populates staff members

                user = await userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    user = new StaffUser {
                        UserName = email
                    };
                    IdentityResult result = await userManager.CreateAsync(user, password);

                    if (await roleManager.FindByNameAsync(role) == null)
                    {
                        await roleManager.CreateAsync(new IdentityRole("Staff"));

                        if (result.Succeeded)
                        {
                            await userManager.AddToRoleAsync(user, role);
                        }
                    }
                }

                profile = new StaffProfile
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    Email              = email,
                    EmailNotifications = notify,
                    User = user,
                    Role = role
                };

                context.StaffProfiles.Add(profile);

                // Second identity + person, to test Authorization
                firstName = "Liz";
                lastName  = "Lemon";
                email     = "*****@*****.**";
                notify    = true;
                role      = "Admin";
                password  = "******";

                user = await userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    user = new StaffUser {
                        UserName = email
                    };
                    IdentityResult result = await userManager.CreateAsync(user, password);

                    if (await roleManager.FindByNameAsync(role) == null)
                    {
                        await roleManager.CreateAsync(new IdentityRole("Admin"));

                        if (result.Succeeded)
                        {
                            await userManager.AddToRoleAsync(user, role);
                        }
                    }
                }

                profile = new StaffProfile
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    Email              = email,
                    EmailNotifications = notify,
                    User = user,
                    Role = role
                };

                context.StaffProfiles.Add(profile);

                // Second identity + person, to test Authorization
                firstName = "Ad";
                lastName  = "Min";
                email     = "*****@*****.**";
                notify    = false;
                role      = "Admin";
                password  = "******";

                user = await userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    user = new StaffUser {
                        UserName = email
                    };
                    IdentityResult result = await userManager.CreateAsync(user, password);

                    if (await roleManager.FindByNameAsync(role) == null)
                    {
                        await roleManager.CreateAsync(new IdentityRole("Admin"));

                        if (result.Succeeded)
                        {
                            await userManager.AddToRoleAsync(user, role);
                        }
                    }
                }

                profile = new StaffProfile
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    Email              = email,
                    EmailNotifications = notify,
                    User = user,
                    Role = role
                };

                context.StaffProfiles.Add(profile);

                context.SaveChanges();
            }

            //Populates Brokers
            if (!context.Brokers.Any())
            {
                //Not specifying a status should default to active
                Broker broker = new Broker {
                    FirstName          = "Lonny",
                    LastName           = "Jenkins",
                    Email              = "*****@*****.**",
                    EmailNotifications = true,
                    Type = "New Broker"
                };

                context.Brokers.Add(broker);
                //Not specifying a status shoudl default to active
                broker = new Broker {
                    FirstName          = "Samantha",
                    LastName           = "Coldwater",
                    Email              = "*****@*****.**",
                    EmailNotifications = true,
                    Type = "In Transition"
                };

                context.Brokers.Add(broker);

                broker = new Broker {
                    FirstName          = "Brooke",
                    LastName           = "Schelling",
                    Email              = "*****@*****.**",
                    EmailNotifications = true,
                    Type   = "New Broker",
                    Status = "Inactive"
                };

                context.Brokers.Add(broker);

                broker = new Broker {
                    FirstName          = "Jack",
                    LastName           = "Johnson",
                    Email              = "*****@*****.**",
                    EmailNotifications = false,
                    Type = "In Transition",
                };

                context.Brokers.Add(broker);

                broker = new Broker
                {
                    FirstName          = "Janet",
                    LastName           = "Schwimmer",
                    Email              = "*****@*****.**",
                    EmailNotifications = true,
                    Type = "In Transition",
                };

                context.Brokers.Add(broker);

                broker = new Broker
                {
                    FirstName          = "Wyatt",
                    LastName           = "Earp",
                    Email              = "*****@*****.**",
                    EmailNotifications = false,
                    Type = "In Transition",
                };

                context.Brokers.Add(broker);

                broker = new Broker
                {
                    FirstName          = "Richard",
                    LastName           = "Kimble",
                    Email              = "*****@*****.**",
                    EmailNotifications = false,
                    Type = "New Broker",
                };

                context.Brokers.Add(broker);

                broker = new Broker
                {
                    FirstName          = "Ty",
                    LastName           = "Burrell",
                    Email              = "*****@*****.**",
                    EmailNotifications = true,
                    Type = "New Broker",
                };

                context.Brokers.Add(broker);

                context.SaveChanges();
            }

            //Populate Messages
            if (!context.Messages.Any())
            {
                StaffProfile profile = context.StaffProfiles.First();
                Message      message = new Message {
                    Subject = "Staff Meeting", Body = "Don't forget we have a morning meeting tomorrow", From = "*****@*****.**", DateSent = DateTime.Now
                };
                Message message2 = new Message {
                    Subject = "Broker Meeting", Body = "All Brokers please make sure you meet us at the office tomorrow", From = "*****@*****.**", DateSent = DateTime.Parse("May 4, 2017")
                };

                context.Messages.Add(message);
                context.Messages.Add(message2);

                context.SaveChanges();
            }

            //Populates Interactions
            //if (!context.Interactions.Any())
            //{
            //    Broker lonny = context.Brokers.First();
            //    StaffProfile profile = context.StaffProfiles.First();
            //    if (Helper.StaffProfileLoggedIn == null)
            //    {
            //        Helper.StaffProfileLoggedIn = profile;
            //    }
            //    Interaction i = new Interaction { Notes = "Interaction Numero Uno", NextStep = "Do the thing" };
            //    Interaction i1 = new Interaction { Notes = "Interaction: The seconding", NextStep = "Do the other thing" };

            //    context.Interactions.Add(i);
            //    context.Interactions.Add(i1);

            //    profile.Interactions.Add(i);
            //    profile.Interactions.Add(i1);

            //    lonny.Interactions.Add(i);
            //    lonny.Interactions.Add(i1);

            //    context.SaveChanges();
            //}

            //Populates KWTasks
            if (!context.KWTasks.Any())
            {
                StaffProfile profile = context.StaffProfiles.First();

                KWTask kwt1 = new KWTask {
                    Message = "A task to be accomplished", Priority = 3, Type = "Alert", DateDue = Convert.ToDateTime("4/22/2017")
                };
                KWTask kwt2 = new KWTask {
                    Message = "Enjoy your day", Priority = 5, Type = "Alert", DateDue = Convert.ToDateTime("4/12/2017")
                };

                context.KWTasks.Add(kwt1);
                context.KWTasks.Add(kwt2);

                profile.Tasks.Add(kwt1);

                context.SaveChanges();
            }
        }