Example #1
0
        protected async override Task OnInitializedAsync()
        {
            Departments = (await DepartmentService.GetDepartments()).ToList();
            int.TryParse(Id, out int employeeid);

            if (employeeid == 0)
            {
                Employee = new Employee
                {
                    DepartmentId = 2,
                    DateOfBirth  = DateTime.Now,
                    PhotoPath    = "images/nophoto.jpg"
                };

                FormHeaderText = "Add Employee";
            }
            else
            {
                FormHeaderText = "Edit Employee";
                Employee       = await EmployeeService.GetEmployee(int.Parse(Id));
            }
            Imapper.Map(Employee, EmployeeEditModelObject);

            //EmployeeEditModelObject.EmployeeId = Employee.EmployeeId;
            //EmployeeEditModelObject.FirstName = Employee.FirstName;
            //EmployeeEditModelObject.LastName = Employee.LastName;
            //EmployeeEditModelObject.Email = Employee.Email;
            //EmployeeEditModelObject.ConfirmEmail = Employee.Email;
            //EmployeeEditModelObject.Gender = Employee.Gender;
            //EmployeeEditModelObject.DepartmentId = Employee.DepartmentId;
            //EmployeeEditModelObject.Department = Employee.Department;
            //EmployeeEditModelObject.DateOfBirth = Employee.DateOfBirth;
            //EmployeeEditModelObject.PhotoPath = Employee.PhotoPath;
        }
Example #2
0
        public async Task HandleValidSubmit()
        {
            Imapper.Map(EmployeeEditModelObject, Employee);

            try
            {
                if (Employee.EmployeeId != 0)
                {
                    var result = await EmployeeService.UpdateEmployee(Employee);
                }
                else
                {
                    var result = await EmployeeService.AddEmployee(Employee);
                }

                NavigationManager.NavigateTo("/");
            }
            catch (Exception ex)
            {
            }
        }