예제 #1
0
        public EmployeeFormModel GetEmployeeFormData(BaseViewModel model)
        {
            IUnitOfWork       uwork    = new UnitOfWork();
            EmployeeFormModel formData = new EmployeeFormModel();

            ICountryService countrySerivce = new CountryService(new CountryRepository(uwork));
            //  IDivisionService divisionService = new DivisionService(new DivisionRepository(uwork));
            IDepartmentService  departmentService = new DepartmentService(new DepartmentRepository(uwork));
            IRoleService        roleService       = new RoleService(new RoleRepository(uwork));
            IBranchService      branchService     = new BranchService(new BranchRepository(uwork));
            IBankService        bankService       = new BankService(new BankRepository(uwork));
            IBankBranchService  bankBranchService = new BankBranchSerivce(new BankBranchRepository(uwork));
            IBankAccountService banAccService     = new BankAccountService(new BankAccountRepository(uwork));
            ILanguageService    langService       = new LanguageService(new LanguageRepository(uwork));
            IApplicationService appService        = new ApplicationService(new ApplicationRepository(uwork));

            basemodel.CurrentCulture = model.CurrentCulture;
            basemodel.CurrentUserID  = model.CurrentUserID;

            var  LastEmployee = GetEmployeeList(basemodel).LastOrDefault();
            long NextID       = LastEmployee == null ? 0 : LastEmployee.RegistrationID + 1;

            try
            {
                formData.countries = countrySerivce.GetAllCountryList(model).Where(c => c.IsActive == true).ToList();
                // formData.divisions = divisionService.GetDivisionList(model);
                formData.departments      = departmentService.GetAllDepartmentList(model).Where(c => c.IsActive == true).ToList();
                formData.roles            = roleService.GetAllRoleList(model).Where(c => c.IsActive == true).ToList();
                formData.branches         = branchService.GetAllBranchList(model).Where(c => c.IsActive == true).ToList();
                formData.banks            = bankService.GetAllBankList(model).Where(c => c.IsActive == true).ToList();
                formData.bankbranches     = bankBranchService.GetAllBankBranchList(model).Where(c => c.IsActive == true).ToList();
                formData.bankAccountTypes = banAccService.GetAllBankAccountType(model).Where(c => c.IsActive == true).ToList();
                formData.languages        = langService.GetAllLanguageList(model).Where(c => c.IsActive == true).ToList();
                //formData.EmployeeNo = Helper.GenerateUniqueID(appService.GetApplicationCode(model.ApplicationId), NextID.ToString());
            }
            catch (Exception ex)
            {
                string message = LogException(ex, model.CurrentUserID);
                throw new Exception(message);
            }
            return(formData);
        }