private void LoadFormWithData() { if (_employeeInformationList == null || _employeeInformationList.Count <= 0) { _isAddNewMode = true; return; } _employeeInformation = _employeeInformationList[_currentIndex]; txtEmployeeId.Text = Convert.ToString(_employeeInformation.Id); txtEmployeeName.Text = _employeeInformation.Name; txtEmployeeCode.Text = _employeeInformation.EmployeeCode; cbxTitle.SelectedValue = _employeeInformation.Title; cbxDepartment.SelectedValue = _employeeInformation.DepartmentId; cbxDesignation.SelectedValue = _employeeInformation.DesignationId; txtPhone.Text = _employeeInformation.Phone; txtMobile.Text = _employeeInformation.Mobile; txtEmail.Text = _employeeInformation.Email; txtBirthDate.Text = Convert.ToString(_employeeInformation.BirthDate); txtJoinDate.Text = Convert.ToString(_employeeInformation.JoiningDate); cbxGender.SelectedValue = _employeeInformation.Gender; cbxMaritalStatus.SelectedValue = _employeeInformation.MaritalStatus; txtReligion.Text = _employeeInformation.Religion; txtNationality.Text = _employeeInformation.Nationality; txtNationalId.Text = _employeeInformation.NationalId; txtPermanentAddress.Text = _employeeInformation.Address1; txtPresentAddress.Text = _employeeInformation.Address2; chkIsActive.Checked = _employeeInformation.IsActive; dgvEmployeeList.Rows[_currentIndex].Selected = true; dgvEmployeeList.CurrentCell = dgvEmployeeList.Rows[_currentIndex].Cells[0]; _isChanged = false; _isAddNewMode = false; }
public void verify_page_returned_on_invalid_model_state_onpost() { // Arrange var httpContext = new DefaultHttpContext(); var modelState = new ModelStateDictionary(); var actionContext = new ActionContext(httpContext, new RouteData(), new PageActionDescriptor(), modelState); var modelMetadataProvider = new EmptyModelMetadataProvider(); var viewData = new ViewDataDictionary(modelMetadataProvider, modelState); var tempData = new TempDataDictionary(httpContext, A.Fake <ITempDataProvider>()); var pageContext = new PageContext(actionContext) { ViewData = viewData }; var objectUnderTest = new EmployeeInformationModel(A.Fake <IDeductionCalculationService>()) { PageContext = pageContext, TempData = tempData, Url = new UrlHelper(actionContext) }; objectUnderTest.ModelState.AddModelError("Employee.Name", "Name is required."); // Act var result = objectUnderTest.OnPost(); // Assert Assert.IsInstanceOfType(result, typeof(PageResult)); }
public void verify_calculation_and_redirect_onpost() { // Arrange var httpContext = new DefaultHttpContext(); var modelState = new ModelStateDictionary(); var actionContext = new ActionContext(httpContext, new RouteData(), new PageActionDescriptor(), modelState); var modelMetadataProvider = new EmptyModelMetadataProvider(); var viewData = new ViewDataDictionary(modelMetadataProvider, modelState); var tempData = new TempDataDictionary(httpContext, A.Fake <ITempDataProvider>()); var pageContext = new PageContext(actionContext) { ViewData = viewData }; IDeductionCalculationService deductionCalculationService = A.Fake <IDeductionCalculationService>(); var objectUnderTest = new EmployeeInformationModel(deductionCalculationService) { PageContext = pageContext, TempData = tempData, Url = new UrlHelper(actionContext) }; // Act var result = objectUnderTest.OnPost(); // Assert Assert.IsInstanceOfType(result, typeof(RedirectToPageResult)); Assert.IsTrue(((RedirectToPageResult)result).PageName == Paylocity.CodingChallenge.Web.Code.Constants.RESULTS_PAGE); A.CallTo(() => deductionCalculationService.CalculateDeductions(A <Employee> ._)).MustHaveHappened(); }
public EmployeeInformationForm() { InitializeComponent(); IKernel kernel = BootStrapper.Initialize(); _employeeInformationService = kernel.GetService(typeof(EmployeeInformationService)) as EmployeeInformationService; _departmentService = kernel.GetService(typeof(DepartmentService)) as DepartmentService; _designationService = kernel.GetService(typeof(DesignationService)) as DesignationService; _employeeInformation = new EmployeeInformationModel(); }
public void verify_dependenttypelist_setup_in_constructor() { // Arrange var objectUnderTest = new EmployeeInformationModel(A.Fake <IDeductionCalculationService>()); // Act // Assert Assert.IsNotNull(objectUnderTest.DependentTypeList); Assert.IsTrue(objectUnderTest.DependentTypeList.Count > 0); }
public void verify_redirect_to_index_page_if_no_numberofdependents_parameter_passed_to_onget() { // Arrange var objectUnderTest = new EmployeeInformationModel(A.Fake <IDeductionCalculationService>()); // Act var result = objectUnderTest.OnGet(null); // Assert Assert.IsInstanceOfType(result, typeof(RedirectToPageResult)); Assert.IsTrue(((RedirectToPageResult)result).PageName == Paylocity.CodingChallenge.Web.Code.Constants.INDEX_PAGE); }
public async Task <ActionResult> UpdateDetails(EmployeeInformationModel model) { HttpCookie WeedHackSesh = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"]; var UserDetails = MvcApplication.Sessions[WeedHackSesh.Value].User; var EmployeeDetails = WeedHackersContext.Employees.ToList().Find(u => u.Id == UserDetails.Id); if (ModelState.IsValid) { var cryptionHelper = new FrostAura.Dynamics.Core.Helpers.FaCryptographyHelper(); if (model.email == null) { model.email = UserDetails.Email; } UserDetails.Email = model.email; if (model.password == null) { model.password = UserDetails.Password; } UserDetails.Password = cryptionHelper.HashString(model.password); if (model.phonenumber == null) { model.phonenumber = UserDetails.PhoneNumber; } UserDetails.PhoneNumber = model.phonenumber; WeedHackersContext.Users.AddOrUpdate(u => u.Id, UserDetails); WeedHackersContext.Employees.AddOrUpdate(c => c.Id, EmployeeDetails); await WeedHackersContext.SaveChangesAsync(); return(RedirectToAction("Index")); } ModelState.AddModelError(model.phonenumber, "Could not add!"); FlashMessage.Danger("Update Unsuccessful", "We could not update your profile. Please ensure you have filled out your new details correctly and try again."); if (EmployeeDetails.EmployeeType.Name == "Employee") { return(RedirectToAction("EmployeeHome")); } else if (EmployeeDetails.EmployeeType.Name == "Manager") { return(RedirectToAction("ManagerHome")); } else { return(RedirectToAction("Index")); } //=============================================================== }
public void verify_page_shown_if_numberofdependents_passed_to_onget() { // Arrange var objectUnderTest = new EmployeeInformationModel(A.Fake <IDeductionCalculationService>()); // Act var result = objectUnderTest.OnGet(3); // Assert Assert.IsInstanceOfType(result, typeof(PageResult)); Assert.IsNotNull(objectUnderTest.Employee.Dependents.Count); Assert.IsTrue(objectUnderTest.Employee.Dependents.Count == 3); }
public async Task <ActionResult> EmployeeJobs(EmployeeInformationModel model) { HttpCookie WeedHackSesh = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"]; var currUser = MvcApplication.Sessions[WeedHackSesh.Value].User; model.EmpServiceRequests = WeedHackersContext .ServiceRequests .Include(srsu => srsu.ServiceRequestStatusUpdates.Select(sv => sv.ServiceStatus)) .Include(s => s.Service) .Include(e => e.LeadEmployee.User) .Include(ea => ea.AssignedEmployees) .Include(c => c.Customer) .Where(sr => sr.ServiceRequestStatusUpdates.Any(srsu => srsu.ServiceStatus.Name == "In Progress") && sr.Service.Department.Id == currUser.Employee.DepartmentId) .ToList(); #region NavigationsForDepartmentEmployee //Navigation for an Employee model.SideNavModels.Add(new NavigationModel { Link = Url.Action("EmployeeHome", "Employee"), Title = "Profile Information", Icon = "fa fa-user-circle-o", Class = "" }); model.SideNavModels.Add(new NavigationModel { Link = Url.Action("EmployeeJobs", "Employee"), Title = "View Jobs", Icon = "fa fa-file-text", Class = "active" }); model.SideNavModels.Add(new NavigationModel { Link = Url.Action("Logout", "Security"), Title = "Sign Out", Icon = "fa fa-plus", Class = "" }); #endregion return(View(model)); }
public async Task <ActionResult> ManagerHome() { HttpCookie WeedHackSesh = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"]; var model = new EmployeeInformationModel(); var currUser = MvcApplication.Sessions[WeedHackSesh.Value].User; model.CurrentEmpUser = currUser; model.CurrentEmployee = currUser.Employee; model.CurrentEmployee.Department = WeedHackersContext.Departments.Single(d => d.Id == currUser.Employee.DepartmentId); #region NavigationsForDepartmentManager //Navigation for an Employee model.SideNavModels.Add(new NavigationModel { Link = Url.Action("ManagerHome", "Employee"), Title = "Profile Information", Icon = "fa fa-user-circle-o", Class = "active" }); model.SideNavModels.Add(new NavigationModel { Link = Url.Action("QuotesForManager", "Employee"), Title = "Accepted Quotes", Icon = "fa fa-file-text", Class = "" }); model.SideNavModels.Add(new NavigationModel { Link = Url.Action("Logout", "Security"), Title = "Sign Out", Icon = "fa fa-plus", Class = "" }); #endregion return(View(model)); }
// GET: Employee public async Task <ActionResult> Index() { var WeedHackSesh = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"].Value; var model = new EmployeeInformationModel(); var currUser = MvcApplication.Sessions[WeedHackSesh].User; model.CurrentEmpUser = currUser; model.CurrentEmployee = currUser.Employee; model.EmpServiceRequests = await WeedHackersContext .ServiceRequests .Include(s => s.Service) .Include(s => s.Customer) .Include(ss => ss.ServiceRequestStatusUpdates.Select(srsu => srsu.ServiceStatus)) //select in this context is a nested include .Where(s => s.ServiceAdvisorId == currUser.Employee.Id && !s.Deleted && !s.IsResolved && s.ServiceRequestStatusUpdates.Any()) //.Any() to cater for service requests without any status .ToListAsync(); #region NavigationsForServiceAdvisorEmployee if (model.CurrentEmployee.EmployeeType.Name == "Employee") { model.SideNavModels.Add(new NavigationModel { Link = Url.Action("EmployeeHome", "Employee"), Title = "Profile Information", Icon = "fa fa-user", Class = "active" }); } if (model.CurrentEmployee.EmployeeType.Name == "Manager") { model.SideNavModels.Add(new NavigationModel { Link = Url.Action("EmployeeHome", "Employee"), Title = "Profile Information", Icon = "fa fa-user", Class = "active" }); } if (model.CurrentEmployee.EmployeeType.Name == "Service Advisor") { model.SideNavModels.Add(new NavigationModel { Link = Url.Action("ManagerHome", "Employee"), Title = "Profile Information", Icon = "fa fa-user", Class = "active" }); } //Navigation for an Employee model.SideNavModels.Add(new NavigationModel { Link = Url.Action("Index", "Employee"), Title = "Open Request", Icon = "fa fa-plus", Class = "active" }); model.SideNavModels.Add(new NavigationModel { Link = Url.Action("Logout", "Security"), Title = "Sign Out", Icon = "fa fa-plus", Class = "active" }); #endregion return(View(model)); }