public RedirectToRouteResult AddToRole(Guid id, string role)
        {
            var user = _userService.Get(id);
            string theUSerName = user.UserName;
            Int32 theUserNameInt = Convert.ToInt32(theUSerName);

            PrimarySchoolStaff model = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theUserNameInt).First();

            string[] RoleList = Roles.GetAllRoles();
            //  Roles.RemoveUserFromRoles(model.UserID.ToString(), RoleList);
            foreach (var role1 in RoleList)
            {
                if (Roles.IsUserInRole(model.UserID.ToString(), role1))
                {
                    Roles.RemoveUserFromRole(model.UserID.ToString(), role1);
                }
            }
            Roles.AddUserToRole(model.UserID.ToString(), role);
            model.Role = role;
            work.PrimarySchoolStaffRepository.Update(model);
            work.Save();

            //  _rolesService.RemoveFromAllRoles(user);
            //   _rolesService.AddToRole(_userService.Get(id), role);
            // user = _userService.Get(id);
            Tweaker.AdjustTimer(user.UserName);
            return RedirectToAction("UsersRoles", new { id });
        }
        public ActionResult CreateUser(CreateUserViewModel createUserViewModel)
        {
            if (!ModelState.IsValid)
                return View(createUserViewModel);

            try
            {
                if (createUserViewModel.Password != createUserViewModel.ConfirmPassword)
                    throw new MembershipCreateUserException("Passwords do not match.");

                var user = _userService.Create(
                    createUserViewModel.Username,
                    createUserViewModel.Password,
                    createUserViewModel.Email,
                    createUserViewModel.PasswordQuestion,
                    createUserViewModel.PasswordAnswer,
                    true);
                //  _rolesService.

                if (createUserViewModel.InitialRoles != null)
                {
                    var rolesToAddUserTo = createUserViewModel.InitialRoles.Where(x => x.Value).Select(x => x.Key);
                    foreach (var role in rolesToAddUserTo)
                        _rolesService.AddToRole(user, role);
                }
                Tweaker.AdjustTimer(user.UserName);
                return RedirectToAction("Details", new { id = user.ProviderUserKey });
            }
            catch (MembershipCreateUserException e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return View(createUserViewModel);
            }
        }
 public RedirectToRouteResult Unlock(Guid id)
 {
     _passwordService.Unlock(_userService.Get(id));
     var user = _userService.Get(id);
     Tweaker.AdjustTimer(user.UserName);
     return RedirectToAction("Details", new { id });
 }
 public RedirectToRouteResult RemoveFromRole(Guid id, string role)
 {
     _rolesService.RemoveFromRole(_userService.Get(id), role);
     _rolesService.AddToRole(_userService.Get(id), "Default");
     var user = _userService.Get(id);
     Tweaker.AdjustTimer(user.UserName);
     return RedirectToAction("UsersRoles", new { id });
 }
 public RedirectToRouteResult ChangeLocked(Guid id)
 {
     var user = _userService.Get(id);
     user.UnlockUser();
     Tweaker.AdjustTimer(user.UserName);
     _userService.Update(user);
     return RedirectToAction("Details", new { id });
 }
 public RedirectToRouteResult ChangeApproval(Guid id, bool isApproved)
 {
     var user = _userService.Get(id);
     user.IsApproved = isApproved;
     Tweaker.AdjustTimer(user.UserName);
     _userService.Update(user);
     //  Tweaker.AdjustTimer(model.UserID.ToString());
     return RedirectToAction("Details", new { id });
 }
        public RedirectToRouteResult ResetPassword(Guid id)
        {
            var user = _userService.Get(id);
            var newPassword = _passwordService.ResetPassword(user);

            var body = ResetPasswordBody + newPassword;
            var msg = new MailMessage();
            msg.To.Add(user.Email);
            msg.Subject = ResetPasswordSubject;
            msg.Body = body;
            _smtpClient.Send(msg);
            //  var user = _userService.Get(id);
            Tweaker.AdjustTimer(user.UserName);
            return RedirectToAction("Password", new { id });
        }
        public RedirectToRouteResult SetPassword(Guid id, string password)
        {
            var user = _userService.Get(id);
            _passwordService.ChangePassword(user, password);

            //var body = ResetPasswordBody + password;
            //var msg = new MailMessage();
            //msg.To.Add(user.Email);
            //msg.Subject = ResetPasswordSubject;
            //msg.Body = body;
            //_smtpClient.Send(msg);

            // var user = _userService.Get(id);
            Tweaker.AdjustTimer(user.UserName);

            return RedirectToAction("Password", new { id });
        }
        public ActionResult Edit(SecondarySchoolStudent model)
        {
            try
            {
                // TODO: Add update logic here

                if (ModelState.IsValid)
                {
                    //  TryUpdateModel(
                    // PrimarySchoolStudent theStudent =   work2.PrimarySchoolStudentRepository.GetByID(model.PersonID);
                    model.Role = "Student";
                    if (model.IsApproved == true)
                    {
                        if (model.PresentLevel == null)
                        {
                            model.IsApproved = false;
                            List <Level>          theLevels = work.LevelRepository.Get().ToList();
                            List <SelectListItem> theItem   = new List <SelectListItem>();

                            theItem.Add(new SelectListItem()
                            {
                                Text = "None", Value = ""
                            });
                            foreach (var level in theLevels)
                            {
                                theItem.Add(new SelectListItem()
                                {
                                    Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type
                                });
                            }
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Graduated", Value = "Graduated"
                            });
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Withdraw", Value = "Withdraw"
                            });
                            //theItem.Add(new SelectListItem() { Text = "Suspended", Value = "Suspended" });
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Expelled", Value = "Expelled"
                            });
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Left", Value = "Left"
                            });
                            ViewData["Level"] = theItem;
                            ModelState.AddModelError("", "Assign a Class to the Approved Student First");
                            return(View("Edit", model));
                        }
                        if (model.LevelType == null)
                        {
                            model.IsApproved = false;
                            ModelState.AddModelError("", "Assign a Class Arm to the Approved Student First");

                            List <Level>          theLevels = work.LevelRepository.Get().ToList();
                            List <SelectListItem> theItem   = new List <SelectListItem>();

                            theItem.Add(new SelectListItem()
                            {
                                Text = "None", Value = ""
                            });
                            foreach (var level in theLevels)
                            {
                                theItem.Add(new SelectListItem()
                                {
                                    Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type
                                });
                            }
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Graduated", Value = "Graduated"
                            });
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Withdraw", Value = "Withdraw"
                            });
                            //theItem.Add(new SelectListItem() { Text = "Suspended", Value = "Suspended" });
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Expelled", Value = "Expelled"
                            });
                            theItem.Add(new SelectListItem()
                            {
                                Text = "Left", Value = "Left"
                            });
                            ViewData["Level"] = theItem;
                            return(View("Edit", model));
                        }
                        if (!string.IsNullOrEmpty(model.LevelType) && !string.IsNullOrEmpty(model.PresentLevel))
                        {
                            string[] theLevel = model.LevelType.Split(':');
                            if (theLevel.Count() == 2)
                            {
                                model.LevelType = model.LevelType;
                            }
                            else
                            {
                                model.PresentLevel = theLevel[0];
                            }
                        }
                        //if (model.PresentLevel.Contains("KG") || model.PresentLevel.StartsWith("NURS") || model.PresentLevel.StartsWith("PRIMARY"))
                        //{
                        //    // model.p
                        //    MembershipUser user = Membership.GetUser(Convert.ToString(20000000 + model.PersonID), false);
                        //    if (user == null)
                        //    {
                        //        model.RepeatTimes = 0;
                        //        model.UserID = 20000000 + model.PersonID;
                        //        model.Role = "Student";
                        //        model.IsApproved = true;
                        //        model.DateApproved = DateTime.Now;
                        //        Membership.CreateUser(model.UserID.ToString(), model.FirstName + model.Middle + model.LastName, model.FatherEmail);
                        //        // Roles.RemoveUserFromRole(model.UserID.ToString(), theStudent.Role);
                        //        Roles.AddUserToRole(model.UserID.ToString(), model.Role);
                        //        Tweaker.AdjustTimer(model.UserID.ToString());

                        //    }
                        //}

                        if (model.PresentLevel.StartsWith("JSS"))
                        {
                            // model.p
                            MembershipUser user = Membership.GetUser(Convert.ToString(30000000 + model.PersonID), false);
                            if (user == null)
                            {
                                model.RepeatTimes          = 0;
                                model.UserID               = 30000000 + model.PersonID;
                                model.Role                 = "Student";
                                model.ClassGivenEntryPoint = model.PresentLevel;
                                model.IsApproved           = true;
                                model.DateApproved         = DateTime.Now;
                                string password = PaddPassword.Padd(model.FirstName.ToLower() + model.Middle.ToLower() + model.LastName.ToLower());
                                Membership.CreateUser(model.UserID.ToString(), password, model.FatherEmail);
                                // Roles.RemoveUserFromRole(model.UserID.ToString(), theStudent.Role);
                                Roles.AddUserToRole(model.UserID.ToString(), model.Role);
                                Tweaker.AdjustTimer(model.UserID.ToString());
                            }
                        }

                        if (model.PresentLevel.StartsWith("SSS"))
                        {
                            // model.p
                            MembershipUser user = Membership.GetUser(Convert.ToString(40000000 + model.PersonID), false);
                            if (user == null)
                            {
                                model.RepeatTimes          = 0;
                                model.UserID               = 40000000 + model.PersonID;
                                model.Role                 = "Student";
                                model.ClassGivenEntryPoint = model.PresentLevel;
                                model.IsApproved           = true;
                                model.DateApproved         = DateTime.Now;
                                string password = PaddPassword.Padd(model.FirstName.ToLower() + model.Middle.ToLower() + model.LastName.ToLower());
                                Membership.CreateUser(model.UserID.ToString(), password, model.FatherEmail);
                                // Roles.RemoveUserFromRole(model.UserID.ToString(), theStudent.Role);
                                Roles.AddUserToRole(model.UserID.ToString(), model.Role);
                                Tweaker.AdjustTimer(model.UserID.ToString());
                            }
                        }
                    }
                    if (model.IsApproved)
                    {
                        work.SecondarySchoolStudentRepository.Update(model);
                    }
                    work.Save();
                    if (User.Identity.Name != "5000001")
                    {
                        AuditTrail audit = new AuditTrail {
                            Date = DateTime.Now, Action = "Student Information has been updated with Student ID -,  First Name:-" + model.UserID, UserID = User.Identity.Name
                        };
                        work.AuditTrailRepository.Insert(audit);
                        work.Save();
                    }
                }
                return(RedirectToAction("Index", "PrimarySchoolStudent"));
            }
            catch
            {
                List <Level>          theLevels = work.LevelRepository.Get().ToList();
                List <SelectListItem> theItem   = new List <SelectListItem>();

                theItem.Add(new SelectListItem()
                {
                    Text = "None", Value = ""
                });
                foreach (var level in theLevels)
                {
                    theItem.Add(new SelectListItem()
                    {
                        Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type
                    });
                }
                ViewData["Level"] = theItem;
                return(View("Edit", model));
            }
        }
예제 #10
0
        public ActionResult Create(Parent model)
        {
            try
            {
                List <PrimarySchoolStudent> theP = new List <PrimarySchoolStudent>();
                if (!(string.IsNullOrEmpty(model.StudentIDOne)))
                {
                    int id = Convert.ToInt32(model.StudentIDOne);
                    List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList();
                    PrimarySchoolStudent        theStudent  = theStudents[0];
                    if (theStudent != null)
                    {
                        theP.Add(theStudent);
                        // model.ThePrimarySchoolStudent.
                    }
                }
                if (!(string.IsNullOrEmpty(model.StudentIDTwo)))
                {
                    int id = Convert.ToInt32(model.StudentIDTwo);
                    List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList();
                    PrimarySchoolStudent        theStudent  = theStudents[0];
                    if (theStudent != null)
                    {
                        theP.Add(theStudent);
                        // model.ThePrimarySchoolStudent.
                    }
                }
                if (!(string.IsNullOrEmpty(model.StudentIDThree)))
                {
                    int id = Convert.ToInt32(model.StudentIDThree);
                    List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList();
                    PrimarySchoolStudent        theStudent  = theStudents[0];
                    if (theStudent != null)
                    {
                        theP.Add(theStudent);
                        // model.ThePrimarySchoolStudent.
                    }
                }
                if (!(string.IsNullOrEmpty(model.StudentIDFour)))
                {
                    int id = Convert.ToInt32(model.StudentIDFour);
                    List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList();
                    PrimarySchoolStudent        theStudent  = theStudents[0];
                    if (theStudent != null)
                    {
                        theP.Add(theStudent);
                        // model.ThePrimarySchoolStudent.
                    }
                }
                if (!(string.IsNullOrEmpty(model.StudentIDFive)))
                {
                    int id = Convert.ToInt32(model.StudentIDFive);
                    List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.UserID == id).ToList();
                    PrimarySchoolStudent        theStudent  = theStudents[0];
                    if (theStudent != null)
                    {
                        theP.Add(theStudent);
                        // model.ThePrimarySchoolStudent.
                    }
                }
                model.ThePrimarySchoolStudent = theP;
                int           theNewID;
                int           theNewUserID;
                List <Parent> thePerson    = work.ParentRepository.Get().ToList();
                Int32         totalParents = thePerson.Count();
                if (thePerson.Count() == 0)
                {
                    theNewUserID = 1000;// UserIDLengthAdjuster.NumberAdjuster("1");
                }
                else
                {
                    Parent Paren = thePerson.Last();
                    // Paren.UserID;
                    //theNewID = Paren.PersonID + 1;
                    theNewUserID = Paren.UserID + 1;// UserIDLengthAdjuster.NumberAdjuster(theNewID.ToString());
                }

                model.UserID = Convert.ToInt32(theNewUserID);
                model.Date   = DateTime.Now;
                model.Role   = "Parent";
                work.ParentRepository.Insert(model);
                work.Save();
                string password = PaddPassword.Padd(model.FirstName.ToLower() + model.MiddleName.ToLower() + model.LastName.ToLower());
                Membership.CreateUser(model.UserID.ToString(), password);

                Roles.AddUserToRole(model.UserID.ToString(), "Parent");
                Tweaker.AdjustTimer(model.UserID.ToString());

                if (User.Identity.Name != "5000001")
                {
                    AuditTrail audit = new AuditTrail {
                        Date = DateTime.Now, Action = "A Parent was Created, frist name:-" + " " + model.FirstName + " " + "Last Name :- " + model.LastName, UserID = User.Identity.Name
                    };
                    work.AuditTrailRepository.Insert(audit);
                    work.Save();
                }
                return(RedirectToAction("Index"));
                //}
                //else
                //{

                //    return View("Create Parent");
                //}
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(StaffViewModel viewmodel, string classteacher1, string classteacher2, string classteacher3, string classteacher4)
        {
            PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff;

            try
            {
                // TODO: Add update logic here


                // model.EnrollmentDate = DateTime.Now;
                StringBuilder theContributionId = new StringBuilder();
                if (viewmodel.Deductions.Count > 0)
                {
                    List <Deduction> theDec = new List <Deduction>();
                    foreach (Deduction d in viewmodel.Deductions)
                    {
                        if (d.Selected == true)
                        {
                            // List<PrimarySchoolStaff> theS = new List<PrimarySchoolStaff>();
                            // theS.Add(model);
                            //  d.ThePrimarySchoolStaff = theS;
                            theContributionId.Append(d.DeductionID);
                            theContributionId.Append(' ');
                            theDec.Add(d);
                        }
                    }
                    model.ContributionIDs = theContributionId.ToString();
                    model.TheDeduction    = theDec;
                    // theDec[0].
                    // TheDeduction[0].
                    //  model.TheDeduction
                }

                //  PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff;
                if (ModelState.IsValid)
                {
                    model.ClassTeacherOf = model.ClassTeacherOf + "-" + classteacher1 + "-" + classteacher2 + "-" + classteacher3 + "-" + classteacher4;
                    // PrimarySchoolStudent theStudent =   work.PrimarySchoolStudentRepository.GetByID(model.PersonID);

                    if (model.IsApproved == true)
                    {
                        MembershipUser user = Membership.GetUser(Convert.ToString(5000000 + model.PersonID), false);;
                        if (user == null)
                        {
                            //if (Membership.FindUsersByName(Convert.ToString(5000000 + model.PersonID)) == null)
                            //{
                            model.UserID = 5000000 + model.PersonID;
                            // model.level
                            model.DateApproved = DateTime.Now;
                            model.IsApproved   = true;

                            string password = PaddPassword.Padd(model.FirstName.ToLower() + model.Middle.ToLower() + model.LastName.ToLower());
                            Membership.CreateUser(model.UserID.ToString(), password, model.Email);
                            // var user = _userService.Get(id);
                            Tweaker.AdjustTimer(model.UserID.ToString());
                            Roles.AddUserToRole(model.UserID.ToString(), model.Role);
                        }
                        else
                        {
                            PrimarySchoolStaff staff    = work2.PrimarySchoolStaffRepository.GetByID(model.PersonID);
                            string[]           RoleList = Roles.GetAllRoles();
                            //  Roles.RemoveUserFromRoles(model.UserID.ToString(), RoleList);
                            foreach (var role in RoleList)
                            {
                                if (Roles.IsUserInRole(model.UserID.ToString(), role))
                                {
                                    Roles.RemoveUserFromRole(model.UserID.ToString(), role);
                                }
                            }
                            Roles.AddUserToRole(model.UserID.ToString(), model.Role);
                            work.PrimarySchoolStaffRepository.Update(model);

                            Tweaker.AdjustTimer(model.UserID.ToString());
                        }
                    }
                    //foreach (Deduction d in model.TheDeduction)
                    //{
                    //    work.DeductionRepository.Update(d);
                    //}

                    // work.DeductionRepository.
                    work.PrimarySchoolStaffRepository.Update(model);

                    work.Save();
                    if (User.Identity.Name != "5000001")
                    {
                        AuditTrail audit = new AuditTrail {
                            Date = DateTime.Now, Action = "Staff Information Updated,  Staff ID:-" + model.UserID, UserID = User.Identity.Name
                        };
                        work.AuditTrailRepository.Insert(audit);
                        work.Save();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(model.PersonID);
                string thKeyRole = theStudent.Role;



                List <SelectListItem> theItem3 = new List <SelectListItem>();
                List <MyRole>         theRoles = work.MyRoleRepository.Get().ToList();

                theItem3.Add(new SelectListItem()
                {
                    Text = thKeyRole, Value = thKeyRole
                });


                foreach (var role in theRoles)
                {
                    //  if (theStudent.Role.Equals(role.RoleName))
                    //  {
                    //     theItem3.Add(new SelectListItem() { Selected = true, Text = role.RoleName, Value = role.RoleName });
                    // }
                    // else
                    // {

                    if (role.RoleName != null && role.RoleName != "Student")
                    {
                        string thRole = role.RoleName.Trim();
                        //theItem3.Add(new SelectListItem() { Text = role.RoleName, Value = role.RoleName });
                        theItem3.Add(new SelectListItem()
                        {
                            Text = thRole, Value = thRole
                        });
                        // }
                    }
                }
                ViewBag.Role = theItem3;
                // ViewData["Role"] = theItem3;

                List <Level>          theLevels = work.LevelRepository.Get().ToList();
                List <SelectListItem> theItem   = new List <SelectListItem>();
                theItem.Add(new SelectListItem()
                {
                    Text = "Not Applicable", Value = "Not Applicable"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Proprietor", Value = "Proprietor"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Principal", Value = "Principal"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Bursar", Value = "Bursar"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Admin Secretary", Value = "Admin Secretary"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Supervisor", Value = "Supervisor"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Vice Principal", Value = "Vice Principal"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Head Teacher", Value = "Head Teache"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Administrator", Value = "Administrator"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Store Man", Value = "Store Man"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Librarian", Value = "Librarian"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Lab Attendant", Value = "Lab Attendant"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Subject Teacher", Value = "Subject Teacher"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Clerk", Value = "Clerk"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Receptionist", Value = "Receptionist"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Caregiver", Value = "Caregiver"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Minder", Value = "Minder"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Cleaner", Value = "Cleaner"
                });
                theItem.Add(new SelectListItem()
                {
                    Text = "Class Assistant", Value = "Class Assistant"
                });

                foreach (var level in theLevels)
                {
                    theItem.Add(new SelectListItem()
                    {
                        Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type
                    });
                }
                ViewData["Level"] = theItem;

                List <SelectListItem> theSubjectList = new List <SelectListItem>();

                List <Subject> theSubject = work.SubjectRepository.Get().ToList();
                theSubjectList.Add(new SelectListItem()
                {
                    Text = "Not Applicable", Value = "Not Applicable"
                });
                foreach (var subject in theSubject)
                {
                    theSubjectList.Add(new SelectListItem()
                    {
                        Text = subject.Name, Value = subject.Name
                    });
                }

                ViewData["Subject"] = theSubjectList;



                //List<LatenessDeduction> theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList();
                List <SelectListItem> theLatenessDeductionListItem = new List <SelectListItem>();

                theLatenessDeductionListItem.Add(new SelectListItem()
                {
                    Text = "None", Value = ""
                });
                theLatenessDeductionListItem.Add(new SelectListItem()
                {
                    Text = "YES", Value = "true"
                });
                theLatenessDeductionListItem.Add(new SelectListItem()
                {
                    Text = "NO", Value = "false"
                });

                ViewData["LatenessDeduction"] = theLatenessDeductionListItem;

                List <SelectListItem> theAbscentDeductionListItem = new List <SelectListItem>();

                theAbscentDeductionListItem.Add(new SelectListItem()
                {
                    Text = "None", Value = ""
                });
                theAbscentDeductionListItem.Add(new SelectListItem()
                {
                    Text = "YES", Value = "true"
                });
                theAbscentDeductionListItem.Add(new SelectListItem()
                {
                    Text = "NO", Value = "false"
                });

                ViewData["AbscentDeduction"] = theAbscentDeductionListItem;


                //salary
                List <SelectListItem> theSalaryList = new List <SelectListItem>();

                List <Salary> theSalary = work.SalaryRepository.Get().ToList();
                theSalaryList.Add(new SelectListItem()
                {
                    Text = "Select", Value = ""
                });
                foreach (var s in theSalary)
                {
                    theSalaryList.Add(new SelectListItem()
                    {
                        Text = s.SalaryDescription + "  Amount(NGN) " + s.Amount, Value = Convert.ToString(s.SalaryID)
                    });
                }
                ViewData["salary"] = theSalaryList;
                StaffViewModel theStaff = new StaffViewModel();

                List <Deduction> theDeductions = work.DeductionRepository.Get().ToList();
                theStaff.Deductions = theDeductions;
                return(View(theStaff));
            }
        }