public void CancelDelegation_Valid()
        {
            // Arrange
            var controller = new DepartmentAPIController()
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration(),
                Context       = context,
            };

            delegationService.DelegateManagerRole("*****@*****.**", "*****@*****.**", "Sat Jul 28 00:00:00 GMT + 08:00 2018", "Sun Jul 29 00:00:00 GMT+08:00 2018");

            // Act
            var latestDelegation           = delegationService.FindAllDelegations().OrderByDescending(d => d.DelegationId).FirstOrDefault();
            IHttpActionResult actionResult = controller.CancelDelegation(new CancelDelegationViewModel()
            {
                DelegationId = latestDelegation.DelegationId,
                HeadEmail    = "*****@*****.**",
            });
            var contentResult = actionResult as OkNegotiatedContentResult <MessageViewModel>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(contentResult.Content.Message, "Successfully cancelled");
            Assert.AreEqual(3, delegationService.FindAllDelegations().OrderByDescending(d => d.DelegationId).FirstOrDefault().Status.StatusId);
        }
Exemple #2
0
        public void DelegateManagerRole_Valid()
        {
            // Arrange

            // Act
            delegationService.DelegateManagerRole("*****@*****.**", "*****@*****.**", "Sat Jul 28 00:00:00 GMT + 08:00 2018", "Sun Jul 29 00:00:00 GMT+08:00 2018");

            // Assert
            Assert.IsTrue(userService.FindRolesByEmail("*****@*****.**").Contains("DepartmentHead"));
            Assert.AreEqual("*****@*****.**", delegationService.FindAllDelegations().OrderByDescending(d => d.DelegationId).FirstOrDefault().Receipient.Email);
        }
        public IActionResult ViewDelegateSummary()
        {
            DelegationViewModel dVModel = new DelegationViewModel();

            empCheck               = JsonConvert.DeserializeObject <Employee>(HttpContext.Session.GetString("employee")) as Employee;
            dVModel.employee       = empCheck;
            dVModel.delegationList = delService.FindAllDelegations(empCheck.Department);
            dVModel.DepartmentHead = empService.FindDeptHead(empCheck);
            return(View("DelegateSummary", dVModel));
        }
        public IActionResult ViewDelegateSummary(int id)
        {
            Employee employee = empService.GetEmployeeById(id);

            if (employee.EmployeeType.EmployeeTypeName.Equals("Department Head"))
            {
                DelegationViewModel dVModel = new DelegationViewModel();
                dVModel.employee       = employee;
                dVModel.delegationList = delegationService.FindAllDelegations(employee.Department);
                dVModel.DepartmentHead = empService.FindDeptHead(employee);
                return(Ok(dVModel));
            }
            else
            {
                return(null);
            }
        }