private void OnSaveEmployeeForm()
        {
            OleDbCommand dbCommand = new OleDbCommand();

            dbCommand.Connection = EmployeeListModel.DataBaseModel.dbConnection;
            if (EmployeeListModel.Nik != "")
            {
                if (EmployeeListModel.IsNikEditable == true)
                {
                    dbCommand.CommandText = "INSERT INTO tbEmployeeList (NIK,NameEmp,Occupation) VALUES ('" + EmployeeListModel.Nik + "','" + EmployeeListModel.Name + "','" + EmployeeListModel.Occupation + "')";
                    dbCommand.ExecuteNonQuery();
                }
                else
                {
                    dbCommand.CommandText = "UPDATE tbEmployeeList SET NameEmp = '" + EmployeeListModel.Name + "', Occupation = '" + EmployeeListModel.Occupation + "' WHERE NIK = '" + EmployeeListModel.Nik + "'";
                    dbCommand.ExecuteNonQuery();
                }
                EmployeeListModel.Refresh();
                MaterialDesignThemes.Wpf.DialogHost.CloseDialogCommand.Execute(null, null);
            }
            else
            {
                System.Windows.MessageBox.Show("Please add NIK");
            }
        }
示例#2
0
        /// <summary>
        /// Created By : Ashwajit Bansod
        /// Created Date : 22-Jan-2019
        /// Created For : To get all employee user ---for now I get all location employee will change it later
        /// </summary>
        /// <param name="LocationId"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public List <EmployeeListModel> GetUserDataList(long LocationId, long UserId)
        {
            var getData     = new EmployeeListModel();
            var getUserList = new List <EmployeeListModel>();

            try
            {
                if (LocationId > 0)
                {
                    ObjectParameter totalRecord = new ObjectParameter("TotalRecords", typeof(int));
                    getUserList = _workorderems.SP_GetAllActiveUser(UserId, 1, "UserId", "Desc", 100, "", 0, "All Users", totalRecord).Select(a => new EmployeeListModel()
                    {
                        UserId   = a.UserId,
                        UserName = a.Name
                    }).ToList();
                }
                else
                {
                    getUserList = null;
                }
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public List<EmployeeListModel> GetUserDataList(long LocationId, long UserId)", "Exception While getting the list of user.", LocationId);
                throw;
            }
            return(getUserList);
        }
示例#3
0
 public EmployeeListViewModel()
 {
     employeeListModel             = EmployeeListModel.Instance;
     ShowAddEmployeeFormCommand    = new DelegateCommand(OnAddEmployeeForm);
     ShowEditEmployeeFormCommand   = new DelegateCommand(OnEditEmployeeForm);
     ShowDeleteEmployeeFormCommand = new DelegateCommand(OnDeleteEmployeeForm);
 }
示例#4
0
        public EmployeeListModel GetEmployee(int id)
        {
            EmployeeListModel       viewModel  = new EmployeeListModel();
            UserPersonalInformation fromDB     = GetEmployeesById(id);
            DepartmentBL            department = new DepartmentBL();
            bool active = false;

            if (fromDB.Active > 0)
            {
                active = true;
            }

            if (fromDB != null)
            {
                viewModel            = new EmployeeListModel();
                viewModel.Active     = active;
                viewModel.Address    = fromDB.Address;
                viewModel.EmployeeId = fromDB.EmployeeId;
                viewModel.FirstName  = fromDB.FirstName;
                viewModel.LastName   = fromDB.LastName;
                viewModel.Position   = fromDB.Position;
                viewModel.BasicPay   = fromDB.BasicPay;
                viewModel.UserPersonalInformationID = fromDB.UserPersonalInformationId;
                if (fromDB.DepartmentId > 0)
                {
                    viewModel.Department = department.GetDepartmentById(fromDB.DepartmentId).DepartmentName;
                }
            }

            return(viewModel);
        }
示例#5
0
        public ActionResult Get()
        {
            var model     = new EmployeeListModel();
            var employees = _empoyeeRepository.EmployeeList.ToList();

            model.List = employees.Adapt <List <EmployeeListItemModel> >();
            return(Ok(model.List));
        }
        public IActionResult Index()
        {
            EmployeeListModel employeeListModel = new EmployeeListModel
            {
                EmployeeLists = IEmployeeServices.EmployeeList().ToList()
            };

            return(View(employeeListModel));
        }
示例#7
0
        public virtual ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmployees))
            {
                return(AccessDeniedView());
            }

            var model = new EmployeeListModel();

            return(View(model));
        }
示例#8
0
 public ActionResult EditEmployee(EmployeeListModel viewModel)
 {
     if (ModelState.IsValid)
     {
         homeHelper.UpdateEmployee(viewModel);
     }
     else
     {
         ModelState.AddModelError("", "Error.");
         return(View(viewModel));
     }
     return(RedirectToAction("Employees", "Home"));
 }
示例#9
0
        public void CreateEmployee(EmployeeListModel viewModel)
        {
            UserPersonalInformation toDB = new UserPersonalInformation();

            toDB.Active     = 1;
            toDB.Address    = viewModel.Address;
            toDB.EmployeeId = viewModel.EmployeeId;
            toDB.FirstName  = viewModel.FirstName;
            toDB.LastName   = viewModel.LastName;
            toDB.Position   = viewModel.Position;
            toDB.BasicPay   = viewModel.BasicPay;
            InsertEmployee(toDB);
        }
示例#10
0
        public ActionResult EditEmployee(int id)
        {
            EmployeeListModel viewModel = new EmployeeListModel();

            if (ModelState.IsValid)
            {
                viewModel = homeHelper.GetEmployee(id);
            }
            else
            {
                ModelState.AddModelError("", "Error.");
                return(View(viewModel));
            }
            return(View(viewModel));
        }
示例#11
0
        async void BtnDeleteSelected_Clicked(object sender, EventArgs e)
        {
            bool rusure = await DisplayAlert("Delete", "Are you sure you want to Delete user: "******"Yes", "Cancel");

            ActivitySpinner.IsRunning = true;
            ActivitySpinner.IsVisible = true;

            try
            {
                if (rusure == true)
                {
                    string empstring = pickEmployee.SelectedItem.ToString();
                    int    end       = empstring.IndexOf(" ", 0);
                    empstring = empstring.Substring(0, end - 0);

                    EmployeeListModel emp = new EmployeeListModel();
                    emp.id = int.Parse(empstring);


                    HttpClient client = new HttpClient();
                    string     url    = Constants.URL + $"/employee/DeleteEmployee/" + empstring;
                    var        uri    = new Uri(url);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpResponseMessage response;
                    var json    = JsonConvert.SerializeObject(emp);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    response = await client.PostAsync(uri, content);

                    if (response.StatusCode == System.Net.HttpStatusCode.Created)
                    {
                        await DisplayAlert("Employee", "Successfully Deleted Employee", "Okay");
                    }
                    else
                    {
                        await DisplayAlert("Job", response.ToString(), "Okay");
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", "Error Deleting Employee", "Okay");
            }


            ActivitySpinner.IsRunning = false;
            ActivitySpinner.IsVisible = false;
        }
示例#12
0
        public ActionResult EmployeeList(EmployeeListModel model)
        {
            var employees = _employeeService.GetAllEmployees(
                email: model.SearchEmail,
                firstName: model.SearchFirstName,
                lastName: model.SearchLastName,
                title: model.SearchTitle,
                pageIndex: model.PageIndex,
                pageSize: model.PageSize);

            return(Json(new
            {
                draw = model.Draw,
                recordsFiltered = 0,
                recordsTotal = employees.TotalCount,
                data = employees
            }));
        }
示例#13
0
        async Task SetEdits()
        {
            try
            {
                string empstring;

                if (Constants.Admin == 1)
                {
                    empstring = pickEmployee.SelectedItem.ToString();
                    int end = empstring.IndexOf(" ", 0);
                    empstring = empstring.Substring(0, end - 0);
                }
                else
                {
                    empstring = (Constants.EmpID).ToString();
                }

                EmployeeListModel item = new EmployeeListModel();
                ActivitySpinner.IsVisible = true;
                HttpClient client = new HttpClient();
                string     url    = Constants.URL + "/employee/GetEmp/" + empstring;
                var        result = await client.GetAsync(url);

                var json = await result.Content.ReadAsStringAsync();

                item             = Newtonsoft.Json.JsonConvert.DeserializeObject <EmployeeListModel>(json);
                emp              = item;
                edtName.Text     = item.EmpName;
                edtSurname.Text  = item.EmpSurname;
                edtPassword.Text = item.EmpPw;
                edtContact.Text  = item.EmpContact;
                if (item.Admin == 1)
                {
                    switchAdmin.IsToggled = true;
                }

                ActivitySpinner.IsVisible = false;
            }
            catch (Exception ex)
            {
                await DisplayAlert("Communication Error", "Error Retrieving", "Okay");
            }
        }
示例#14
0
        public void UpdateEmployee(EmployeeListModel viewModel)
        {
            int active = 0;

            if (viewModel.Active)
            {
                active = 1;
            }
            UserPersonalInformation toDB = new UserPersonalInformation();

            toDB.Active     = active;
            toDB.Address    = viewModel.Address;
            toDB.EmployeeId = viewModel.EmployeeId;
            toDB.FirstName  = viewModel.FirstName;
            toDB.LastName   = viewModel.LastName;
            toDB.Position   = viewModel.Position;
            toDB.BasicPay   = viewModel.BasicPay;
            toDB.UserPersonalInformationId = viewModel.UserPersonalInformationID;

            UpdateEmployee(toDB);
        }
示例#15
0
 public ActionResult CreateEmployee(EmployeeListModel viewModel)
 {
     if (ModelState.IsValid)
     {
         if (employeeBL.CheckIfEmployeeIdExists(viewModel.EmployeeId))
         {
             ModelState.AddModelError("", "Employee ID already exists.");
             return(View(viewModel));
         }
         else
         {
             homeHelper.CreateEmployee(viewModel);
         }
     }
     else
     {
         ModelState.AddModelError("", "Error.");
         return(View(viewModel));
     }
     return(RedirectToAction("Employees", "Home"));
 }
示例#16
0
        public virtual ActionResult List(DataSourceRequest command, EmployeeListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmployees))
            {
                return(AccessDeniedKendoGridJson());
            }

            var Employees = _EmployeeService.GetAllEmployees(model.SearchName, command.Page - 1, command.PageSize, true);
            var gridModel = new DataSourceResult
            {
                Data = Employees.Select(x =>
                {
                    var EmployeeModel = x.ToModel();
                    PrepareEmployeeModel(EmployeeModel, x, false, false);
                    return(EmployeeModel);
                }),
                Total = Employees.TotalCount,
            };

            return(Json(gridModel));
        }
示例#17
0
        private async void OnDeleteEmployeeForm()
        {
            try
            {
                FillDataField();
                var    dialog = new Views.DeleteDialogConfirmView();
                object result = await MaterialDesignThemes.Wpf.DialogHost.Show(dialog, "EmployeeFormDialogHost");

                if (!(result is bool boolResult && boolResult))
                {
                    OleDbCommand dbCommand = new OleDbCommand();
                    dbCommand.Connection  = EmployeeListModel.DataBaseModel.dbConnection;
                    dbCommand.CommandText = "DELETE FROM tbEmployeeList WHERE NIK='" + EmployeeListModel.Nik + "'";
                    dbCommand.ExecuteNonQuery();
                    EmployeeListModel.Refresh();
                }
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Please Select one Item");
            }
        }
示例#18
0
        public ViewResult List(string category, int managerId, int page = 1)
        {
            List <EmployeeModel> employeeModels = null;

            if (managerId == 0)
            {
                employeeModels = _employeeService.GetAll().Select(x => _mapperFactory.MappEmployeeToEmployeeModel <EmployeeModel>(x)).ToList();
            }
            else
            {
                employeeModels = GetTreeEmployeeList(managerId);
            }

            TempData["ManagerId"] = managerId;

            EmployeeListModel model = new EmployeeListModel
            {
                ManagerId = managerId,

                Employees = employeeModels
                            .Where(x => category == null || x.DepartmentName == category)
                            .OrderBy(x => x.FirstName)
                            .Skip((page - 1) * PageSize)
                            .Take(PageSize),

                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = category == null?employeeModels.Count() :
                                       employeeModels.Where(e => e.DepartmentName == category).Count()
                },

                CurrentCategory = category
            };

            return(View(model));
        }
示例#19
0
        public IActionResult ListData(DepartmentSearchModel searchModel)
        {
            if (!_permissionService.Authorize(EmployeePermissionProvider.ManageEmployees))
            {
                return(AccessDeniedView());
            }

            var departmentDict = _employeeService.GetOrderedDepartments(showUnpublished: true).ToDictionary(x => x.Id, x => x);

            var employees = _employeeService.GetOrderedEmployees(showUnpublished: true, searchModel.Page - 1, searchModel.PageSize);
            var model     = new EmployeeListModel().PrepareToGrid(searchModel, employees, () =>
            {
                return(employees.Select(employee =>
                {
                    var e = employee.ToModel();
                    e.DepartmentName = departmentDict[e.DepartmentId].Name;
                    e.DepartmentPublished = departmentDict[e.DepartmentId].Published;
                    return e;
                }));
            });

            return(Json(model));
        }
示例#20
0
        public ActionResult Employees()
        {
            EmployeeListPayrollPeriodViewModel employeeListPayrollPeriod = new EmployeeListPayrollPeriodViewModel();

            List <EmployeeListModel>       employeeListModels = new List <EmployeeListModel>();
            EmployeeListModel              employee           = new EmployeeListModel();
            DepartmentBL                   department         = new DepartmentBL();
            List <UserPersonalInformation> listFromDB         = employeeBL.GetAllEmployees();


            PayrollPeriodBL      payrollPeriodBL = new PayrollPeriodBL();
            List <PayrollPeriod> payrollPeriods  = new List <PayrollPeriod>();

            payrollPeriods = payrollPeriodBL.GetPayrollPeriods();

            foreach (UserPersonalInformation item in listFromDB)
            {
                employee            = new EmployeeListModel();
                employee.Active     = Convert.ToBoolean(item.Active);
                employee.Address    = item.Address;
                employee.EmployeeId = item.EmployeeId;
                employee.FirstName  = item.FirstName;
                employee.LastName   = item.LastName;
                employee.UserPersonalInformationID = item.UserPersonalInformationId;
                employee.Position = item.Position;
                employee.BasicPay = item.BasicPay;
                employee.Name     = item.FirstName + " " + employee.LastName;
                if (item.DepartmentId > 0)
                {
                    employee.Department = department.GetDepartmentById(item.DepartmentId).DepartmentName;
                }
                employeeListModels.Add(employee);
            }
            employeeListPayrollPeriod.EmployeeList   = employeeListModels;
            employeeListPayrollPeriod.PayrollPeriods = new SelectList(payrollPeriods, "PayrollPeriodId", "PayPeriodFrom", 2);
            return(View(employeeListPayrollPeriod));
        }
        public static EmployeeListModel GetEmployees(int pageIndex, int pageSize, string sortOrder, string sortColumn, string searchString, int filterGender, string filterDepartment)
        {
            EmployeeDbContext dbContext2 = new EmployeeDbContext();
            EmployeeListModel model      = new EmployeeListModel();

            model.PageIndex   = pageIndex;
            model.PageSize    = pageSize;
            model.PageContent = true;
            var employeeList = dbContext2.tblEmployees.Where(e => e.FirstName != "admin").Join
                                   (dbContext2.tblQualifications, e => e.QualificationId, q => q.Id, (e, q) => new
            {
                e.ID,
                e.FirstName,
                e.LastName,
                e.Age,
                e.Gender,
                e.DepartmentId,
                e.Address,
                e.City,
                e.State,
                e.CountryId,
                e.DateOfBirth,
                e.Email,
                e.Experience,
                e.Mobile,
                q.Qualification
            })
                               .Join(dbContext2.tblDepartments, s => s.DepartmentId, d => d.Id, (s, d) => new
            {
                s.ID,
                s.FirstName,
                s.LastName,
                s.Age,
                s.Gender,
                s.DepartmentId,
                s.Qualification,
                d.Department,
                s.Address,
                s.City,
                s.State,
                s.CountryId,
                s.DateOfBirth,
                s.Email,
                s.Experience,
                s.Mobile
            })
                               .Join(dbContext2.tblCountries, s => s.CountryId, d => d.Id, (c, f) => new
            {
                c.ID,
                c.FirstName,
                c.LastName,
                c.Age,
                c.Gender,
                c.Qualification,
                c.Department,
                c.Address,
                c.City,
                c.State,
                f.CountryName,
                c.DateOfBirth,
                c.Email,
                c.Experience,
                c.Mobile
            });

            if (!String.IsNullOrEmpty(searchString))
            {
                employeeList = employeeList.Where(e => e.FirstName.ToLower().StartsWith(searchString.ToLower()) || e.LastName.ToLower().StartsWith(searchString.ToLower()));
            }
            if (filterGender > 0)
            {
                employeeList = employeeList.Where(e => e.Age == filterGender);
            }
            if (!String.IsNullOrEmpty(filterDepartment))
            {
                employeeList = employeeList.Where(e => e.Department.ToLower().StartsWith(filterDepartment.ToLower()));
            }
            switch (sortColumn)
            {
            case "FirstName":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.FirstName) : employeeList.OrderBy(e => e.FirstName);
                break;

            case "Age":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Age) : employeeList.OrderBy(e => e.Age);
                break;

            case "Gender":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Gender) : employeeList.OrderBy(e => e.Gender);
                break;

            case "Qualification":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Qualification) : employeeList.OrderBy(e => e.Qualification);
                break;

            case "Department":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Department) : employeeList.OrderBy(e => e.Department);
                break;

            case "City":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.City) : employeeList.OrderBy(e => e.City);
                break;

            case "State":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.State) : employeeList.OrderBy(e => e.State);
                break;

            case "Country":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.CountryName) : employeeList.OrderBy(e => e.CountryName);
                break;

            case "Experience":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Experience) : employeeList.OrderBy(e => e.Experience);
                break;

            case "Email":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Email) : employeeList.OrderBy(e => e.Email);
                break;

            case "Mobile":
                employeeList = (sortOrder.ToLower() == "desc") ? employeeList.OrderByDescending(e => e.Mobile) : employeeList.OrderBy(e => e.Mobile);
                break;

            default:
                employeeList = employeeList.OrderBy(e => e.ID);
                break;
            }
            model.TotalPages = (int)Math.Ceiling((decimal)employeeList.Count() / pageSize);
            if (employeeList.Skip((pageIndex - 1) * model.PageSize).Take(model.PageSize).Count() > 0)
            {
                employeeList = employeeList.Skip((pageIndex - 1) * model.PageSize).Take(model.PageSize);
            }
            else
            {
                model.PageContent = false;
            }
            model.Employees = employeeList.Select(s => new EmployeeModel
            {
                ID            = s.ID,
                FirstName     = s.FirstName,
                LastName      = s.LastName,
                Age           = s.Age,
                Gender        = s.Gender,
                Qualification = s.Qualification,
                Department    = s.Department,
                Address       = s.Address,
                City          = s.City,
                State         = s.State,
                Country       = s.CountryName,
                DateOfBirth   = s.DateOfBirth,
                Experience    = s.Experience,
                Email         = s.Email,
                Mobile        = s.Mobile
            }).ToList();
            return(model);
        }
示例#22
0
        // GET: Employee
        public async Task <IActionResult> Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            ViewBag.CurrentSort        = sortOrder;
            ViewBag.NameSortParm       = String.IsNullOrEmpty(sortOrder) ? "last_name" : "";
            ViewBag.IdSortParm         = String.IsNullOrEmpty(sortOrder) ? "Id" : "";
            ViewBag.FnameSortParm      = String.IsNullOrEmpty(sortOrder) ? "Fname" : "";
            ViewBag.LnameSortParm      = String.IsNullOrEmpty(sortOrder) ? "Lname" : "";
            ViewBag.BirthSortParm      = String.IsNullOrEmpty(sortOrder) ? "Birth" : "";
            ViewBag.SalarySortParm     = String.IsNullOrEmpty(sortOrder) ? "Salary" : "";
            ViewBag.JobSortParm        = String.IsNullOrEmpty(sortOrder) ? "Job" : "";
            ViewBag.PositionSortParm   = String.IsNullOrEmpty(sortOrder) ? "Position" : "";
            ViewBag.DepartmentSortParm = String.IsNullOrEmpty(sortOrder) ? "Department" : "";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var list = await GetEmployeeModelQueryable();

            if (!String.IsNullOrEmpty(searchString))
            {
                list = list.Where(s => s.Last_name.Contains(searchString) ||
                                  s.First_name.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "last_name":
                list = list.OrderByDescending(s => s.Last_name);
                break;

            case "Id":
                list = list.OrderByDescending(s => s.Id);
                break;

            case "Fname":
                list = list.OrderByDescending(s => s.First_name);
                break;

            case "Lname":
                list = list.OrderByDescending(s => s.Last_name);
                break;

            case "Birth":
                list = list.OrderByDescending(s => s.Birth_date);
                break;

            case "Salary":
                list = list.OrderByDescending(s => s.Salary);
                break;

            case "Job":
                list = list.OrderByDescending(s => s.Job);
                break;

            case "Position":
                list = list.OrderByDescending(s => s.Department);
                break;

            case "Department":
                list = list.OrderByDescending(s => s.Department);
                break;

            default:
                list = list.OrderBy(s => s.Id);
                break;
            }

            var pageNumber    = page ?? 1;
            var employeeslist = new EmployeeListModel {
                Employees = list.ToPagedList(pageNumber, 15)
            };

            return(View(employeeslist));
        }
示例#23
0
        public ActionResult Payroll(FormCollection collection)
        {
            var payPeriodId = collection.GetValue("PayrollPeriodId").AttemptedValue;

            if (ModelState.IsValid)
            {
                if (payPeriodId.ToString().Length > 0)
                {
                    List <EmployeeListModel>                employeeListModels                = new List <EmployeeListModel>();
                    EmployeeListModel                       employee                          = new EmployeeListModel();
                    DepartmentBL                            department                        = new DepartmentBL();
                    List <UserPersonalInformation>          listFromDB                        = employeeBL.GetAllEmployees();
                    AssingedEmployeeIncomeBL                assingedEmployeeIncomeBL          = new AssingedEmployeeIncomeBL();
                    List <AssignedEmployeeIncomesViewModel> assignEmployeeIncomeViewModelList = new List <AssignedEmployeeIncomesViewModel>();
                    AssignedEmployeeIncomesViewModel        assignEmployeeIncomeViewModel     = new AssignedEmployeeIncomesViewModel();
                    List <Income>                           incomeDBList                      = new List <Income>();
                    Income   incomeDB = new Income();
                    IncomeBL incomeBL = new IncomeBL();

                    PayrollPeriodBL payrollPeriodBL = new PayrollPeriodBL();
                    PayrollPeriod   payrollPeriodDB = new PayrollPeriod();

                    List <Deduction> deductionDBList = new List <Deduction>();
                    Deduction        deductionDB     = new Deduction();
                    DeductionBL      deductionBL     = new DeductionBL();

                    List <PayrollTransactionIncome> payrollTransactionIncomes  = new List <PayrollTransactionIncome>();
                    PayrollTransactionIncome        payrollTransactionIncome   = new PayrollTransactionIncome();
                    PayrollTransactionIncomeBL      payrollTransactionIncomeBL = new PayrollTransactionIncomeBL();

                    PayrollTransactionDeduction   payrollTransactionDeduction   = new PayrollTransactionDeduction();
                    PayrollTransactionDeductionBL payrollTransactionDeductionBL = new PayrollTransactionDeductionBL();

                    List <PayrollTransactionDeductionViewModels> payrollTransactionDeductionViewModels = new List <PayrollTransactionDeductionViewModels>();
                    PayrollTransactionDeductionViewModels        payrollTransactionDeductionViewModel  = new PayrollTransactionDeductionViewModels();

                    List <PayrollTransactionIncomeViewModels> payrollTransactionIncomeViewModels = new List <PayrollTransactionIncomeViewModels>();
                    PayrollTransactionIncomeViewModels        payrollTransactionIncomeViewModel  = new PayrollTransactionIncomeViewModels();

                    foreach (UserPersonalInformation item in listFromDB)
                    {
                        employee            = new EmployeeListModel();
                        employee.Active     = Convert.ToBoolean(item.Active);
                        employee.Address    = item.Address;
                        employee.EmployeeId = item.EmployeeId;
                        employee.FirstName  = item.FirstName;
                        employee.LastName   = item.LastName;
                        employee.UserPersonalInformationID = item.UserPersonalInformationId;
                        employee.Position = item.Position;
                        employee.BasicPay = item.BasicPay;
                        employee.Name     = item.FirstName + " " + employee.LastName;


                        #region incomes
                        incomeDBList = incomeBL.GetActiveIncomes();
                        if (incomeDBList != null)
                        {
                            foreach (var dbIncome in incomeDBList)
                            {
                                payrollTransactionIncome = new PayrollTransactionIncome();
                                payrollTransactionIncome = payrollTransactionIncomeBL.GetPayrollTransactionIncome(item.UserPersonalInformationId, Convert.ToInt32(payPeriodId), dbIncome.IncomeId);

                                if (payrollTransactionIncome != null)
                                {
                                    payrollTransactionIncomeViewModel = new PayrollTransactionIncomeViewModels();
                                    payrollTransactionIncomeViewModel.PayrollTransactionIncomeId = payrollTransactionIncome.PayrollTransactionIncomeId;
                                    payrollTransactionIncomeViewModel.UserPersonalInformationid  = item.UserPersonalInformationId;
                                    payrollTransactionIncomeViewModel.PayrollPeriodId            = Convert.ToInt32(payPeriodId);


                                    incomeDB = incomeBL.GetIncomesById(Convert.ToInt32(payrollTransactionIncome.IncomeId));
                                    payrollTransactionIncomeViewModel.IncomeId           = Convert.ToInt32(payrollTransactionIncome.IncomeId);
                                    payrollTransactionIncomeViewModel.CustomIncomeAmount = payrollTransactionIncome.CustomIncomeAmount > 0 ? Convert.ToDecimal(payrollTransactionIncome.CustomIncomeAmount) : 0.0M;
                                    //payrollTransactionIncomeViewModel.DefaultIncomeAmount = dbIncome.IncomeAmount > 0 ? Convert.ToDecimal(dbIncome.IncomeAmount) : 0.0M;
                                    payrollTransactionIncomeViewModel.DefaultIncomeName = incomeDB.IncomeName;

                                    payrollTransactionIncomeViewModels.Add(payrollTransactionIncomeViewModel);
                                }
                                else
                                {
                                    PayrollTransactionIncomeViewModels insertView = new PayrollTransactionIncomeViewModels();
                                    insertView.CustomIncomeAmount         = 0.0M;
                                    insertView.PayrollTransactionIncomeId = 0;
                                    insertView.UserPersonalInformationid  = item.UserPersonalInformationId;

                                    incomeDB                      = incomeBL.GetIncomesById(Convert.ToInt32(dbIncome.IncomeId));
                                    insertView.IncomeId           = Convert.ToInt32(dbIncome.IncomeId);
                                    insertView.CustomIncomeAmount = 0.0M;
                                    //insertView.DefaultIncomeAmount = dbIncome.IncomeAmount > 0 ? Convert.ToDecimal(dbIncome.IncomeAmount) : 0.0M;
                                    insertView.DefaultIncomeName = incomeDB.IncomeName;
                                    insertView.PayrollPeriodId   = Convert.ToInt32(payPeriodId);

                                    payrollTransactionIncome = new PayrollTransactionIncome();
                                    payrollTransactionIncome = payrollTransactionIncomeBL.InsertPayrollTransactionIncomes(insertView);
                                    insertView = new PayrollTransactionIncomeViewModels();
                                    insertView.PayrollTransactionIncomeId = payrollTransactionIncome.PayrollTransactionIncomeId;
                                    insertView.UserPersonalInformationid  = item.UserPersonalInformationId;
                                    insertView.PayrollPeriodId            = Convert.ToInt32(payPeriodId);
                                    insertView.IncomeId           = Convert.ToInt32(payrollTransactionIncome.IncomeId);
                                    insertView.CustomIncomeAmount = payrollTransactionIncome.CustomIncomeAmount > 0 ? Convert.ToDecimal(payrollTransactionIncome.CustomIncomeAmount) : 0.0M;
                                    //insertView.DefaultIncomeAmount = dbIncome.IncomeAmount > 0 ? Convert.ToDecimal(dbIncome.IncomeAmount) : 0.0M;
                                    insertView.DefaultIncomeName = incomeDB.IncomeName;
                                    payrollTransactionIncomeViewModels.Add(insertView);
                                }
                            }
                        }
                        #endregion

                        #region deductions
                        deductionDBList = deductionBL.GetActiveDeductions();
                        if (deductionDBList != null)
                        {
                            foreach (var dbDeduction in deductionDBList)
                            {
                                payrollTransactionDeduction = new PayrollTransactionDeduction();
                                payrollTransactionDeduction = payrollTransactionDeductionBL.GetPayrollTransactionDeduction(item.UserPersonalInformationId, Convert.ToInt32(payPeriodId), dbDeduction.DeductionId);

                                if (payrollTransactionDeduction != null)
                                {
                                    payrollTransactionDeductionViewModel = new PayrollTransactionDeductionViewModels();
                                    payrollTransactionDeductionViewModel.PayrollTransactionDeductionId = payrollTransactionDeduction.PayrollTransactionDeductionId;
                                    payrollTransactionDeductionViewModel.UserPersonalInformationid     = item.UserPersonalInformationId;
                                    payrollTransactionDeductionViewModel.PayrollPeriodId = Convert.ToInt32(payPeriodId);


                                    deductionDB = deductionBL.GetDeductionById(Convert.ToInt32(payrollTransactionDeduction.DeductionId));
                                    payrollTransactionDeductionViewModel.DeductionId           = Convert.ToInt32(payrollTransactionDeduction.DeductionId);
                                    payrollTransactionDeductionViewModel.CustomDeductionAmount = payrollTransactionDeduction.CustomDeductionAmount > 0 ? Convert.ToDecimal(payrollTransactionDeduction.CustomDeductionAmount) : 0.0M;
                                    //payrollTransactionIncomeViewModel.DefaultIncomeAmount = dbIncome.IncomeAmount > 0 ? Convert.ToDecimal(dbIncome.IncomeAmount) : 0.0M;
                                    payrollTransactionDeductionViewModel.DefaultDeductionName = deductionDB.DeductionName;

                                    payrollTransactionDeductionViewModels.Add(payrollTransactionDeductionViewModel);
                                }
                                else
                                {
                                    PayrollTransactionDeductionViewModels deductionView = new PayrollTransactionDeductionViewModels();
                                    deductionView.CustomDeductionAmount         = 0.0M;
                                    deductionView.PayrollTransactionDeductionId = 0;
                                    deductionView.UserPersonalInformationid     = item.UserPersonalInformationId;

                                    deductionDB = deductionBL.GetDeductionById(Convert.ToInt32(dbDeduction.DeductionId));
                                    deductionView.DeductionId           = Convert.ToInt32(dbDeduction.DeductionId);
                                    deductionView.CustomDeductionAmount = 0.0M;
                                    //insertView.DefaultIncomeAmount = dbIncome.IncomeAmount > 0 ? Convert.ToDecimal(dbIncome.IncomeAmount) : 0.0M;
                                    deductionView.DefaultDeductionName = incomeDB.IncomeName;
                                    deductionView.PayrollPeriodId      = Convert.ToInt32(payPeriodId);

                                    payrollTransactionDeduction = new PayrollTransactionDeduction();
                                    payrollTransactionDeduction = payrollTransactionDeductionBL.InsertPayrollTransactionDeductions(deductionView);
                                    deductionView = new PayrollTransactionDeductionViewModels();
                                    deductionView.PayrollTransactionDeductionId = payrollTransactionDeduction.PayrollTransactionDeductionId;
                                    deductionView.UserPersonalInformationid     = item.UserPersonalInformationId;
                                    deductionView.PayrollPeriodId       = Convert.ToInt32(payPeriodId);
                                    deductionView.DeductionId           = Convert.ToInt32(payrollTransactionDeduction.DeductionId);
                                    deductionView.CustomDeductionAmount = payrollTransactionDeduction.CustomDeductionAmount > 0 ? Convert.ToDecimal(payrollTransactionDeduction.CustomDeductionAmount) : 0.0M;
                                    //insertView.DefaultIncomeAmount = dbIncome.IncomeAmount > 0 ? Convert.ToDecimal(dbIncome.IncomeAmount) : 0.0M;
                                    deductionView.DefaultDeductionName = incomeDB.IncomeName;
                                    payrollTransactionDeductionViewModels.Add(deductionView);
                                }
                            }
                        }
                        #endregion

                        employee.Incomes = payrollTransactionIncomeViewModels;
                        payrollTransactionIncomeViewModels = new List <PayrollTransactionIncomeViewModels>();
                        employee.Deductions = payrollTransactionDeductionViewModels;
                        payrollTransactionDeductionViewModels = new List <PayrollTransactionDeductionViewModels>();

                        if (item.DepartmentId > 0)
                        {
                            employee.Department = department.GetDepartmentById(item.DepartmentId).DepartmentName;
                        }


                        #region EmployeeDetailsPayrollViewModel
                        EmployeeDetailsPayrollViewModel employeeDetailsPayrollViewModel = new EmployeeDetailsPayrollViewModel();
                        employeeDetailsPayrollViewModel.BasicPay   = employee.BasicPay > 0 ? Convert.ToDecimal(employee.BasicPay) : 0.0M;
                        employeeDetailsPayrollViewModel.Department = employee.Department;
                        employeeDetailsPayrollViewModel.EmployeeId = employee.EmployeeId;
                        employeeDetailsPayrollViewModel.Name       = employee.Name;

                        #endregion

                        #region EmployeePayPeriodDetailsPayrollViewModel
                        payrollPeriodDB = payrollPeriodBL.GetPayrollPeriodById(Convert.ToInt32(payPeriodId));
                        EmployeePayPeriodDetailsPayrollViewModel employeePayPeriodDetailsPayrollViewModel = new EmployeePayPeriodDetailsPayrollViewModel();
                        employeePayPeriodDetailsPayrollViewModel.CurrentPeriodWorkDays  = payrollPeriodDB.WorkDays > 0 ? Convert.ToDecimal(payrollPeriodDB.WorkDays) : 0.0M;
                        employeePayPeriodDetailsPayrollViewModel.CurrentPeriodWorkHours = payrollPeriodDB.WorkHours > 0 ? Convert.ToDecimal(payrollPeriodDB.WorkHours) : 0.0M;;
                        employeePayPeriodDetailsPayrollViewModel.Month         = payrollPeriodDB.Month;
                        employeePayPeriodDetailsPayrollViewModel.PayPeriodFrom = payrollPeriodDB.PayPeriodFrom;
                        employeePayPeriodDetailsPayrollViewModel.PayPeriodTo   = payrollPeriodDB.PayPeriodTo;
                        employeePayPeriodDetailsPayrollViewModel.PayPeriodId   = Convert.ToInt32(payPeriodId);
                        #endregion


                        employee.EmployeeDetailsPayrollViewModel          = employeeDetailsPayrollViewModel;
                        employee.EmployeePayPeriodDetailsPayrollViewModel = employeePayPeriodDetailsPayrollViewModel;
                        employeeListModels.Add(employee);
                    }

                    return(View(employeeListModels));
                }
                else
                {
                    ModelState.AddModelError("", "Choose a pay period.");
                    return(RedirectToAction("Employees", "Home"));
                }
            }
            else
            {
                ModelState.AddModelError("", "Choose a pay period.");
                return(RedirectToAction("Employees", "Home"));
            }
        }
 public EmployeeFormViewModel()
 {
     employeeListModel       = EmployeeListModel.Instance;
     SaveEmployeeFormCommand = new DelegateCommand(OnSaveEmployeeForm);
 }