コード例 #1
0
        public static Employee Get(PersonAPI person, EmployeeEnum empType)
        {
            switch (empType)
            {
            case EmployeeEnum.AssistentLibrarian:
                var assistantLibrarian = new AssistantLibrarian(person);
                return((assistantLibrarian.IsValid()) ? assistantLibrarian : null);

            case EmployeeEnum.CheckOutStaff:
                var checkOutStaff = new CheckOutStaff(person);
                return((checkOutStaff.IsValid()) ? checkOutStaff : null);

            case EmployeeEnum.ChiefLibrarian:
                var chiefLibrarianemp = new ChiefLibrarian(person);
                return((chiefLibrarianemp.IsValid()) ? chiefLibrarianemp : null);

            case EmployeeEnum.DepartmentLibrarian:
                var departmentLibrarian = new DepartmentLibrarian(person);
                return((departmentLibrarian.IsValid()) ? departmentLibrarian : null);

            case EmployeeEnum.ReferenceLibrarian:
                var referenceLibrarian = new ReferenceLibrarian(person);
                return((referenceLibrarian.IsValid()) ? referenceLibrarian : null);
            }
            return(null);
        }
コード例 #2
0
        public IActionResult Add()
        {
            var model = new StaffAddModelHybrid {
                RoleList = EmployeeEnum.RoleList()
            };

            return(View(model));
        }
コード例 #3
0
        public void Factory_Create_Employee(string expected, EmployeeEnum empType)
        {
            //Arrange
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = "*****@*****.**", Name = "Michael Schumacher", Password = "******", Phone = "4569637412", PictureId = "testpictureid1", Ssn = 999555111
            };

            //Act
            Employee emp = EmployeeFactory.Get(person, empType);

            //Assert
            Assert.Equal(expected, emp.Title);
        }
コード例 #4
0
        public async void Add_Employee(string expected, EmployeeEnum empType)
        {
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = "*****@*****.**", Name = "Michael Schumacher", Password = "******", Phone = "1122336652", PictureId = "testpictureid1", Ssn = 999557811
            };

            using (var context = GetContextWithData())
                using (var controller = new EmployeesController(context))
                {
                    var result = await controller.PostEmployee(person, (int)empType);

                    var emp = context.Employees.FirstOrDefault(e => e.Ssn == person.Ssn);
                    Assert.Equal(expected, emp.Title);
                }
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id != null)
            {
                var result = await repositoryHandler.GetEntryByIDAsync(id.Value);

                var model = new StaffEditModelHybrid
                {
                    StaffId   = result.Id,
                    ShortName = result.ShortName,
                    FullName  = result.FullName,
                    Email     = result.Email,
                    Role      = (int)result.Role.Name,
                    RoleList  = EmployeeEnum.RoleList((int)result.Role.Name)
                };
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }