コード例 #1
0
        public EmployeeViewModel Add(EmployeeViewModel vm)
        {
            var temp = _mapper.Map <EmployeeViewModel, Employee>(vm);

            _employeeReponsitory.Add(temp);
            return(vm);
        }
コード例 #2
0
        public void HandleExcelFile(FileInfo fileInfo, int requestId)
        {
            using (ExcelPackage excel = new ExcelPackage(fileInfo))
            {
                ExcelWorksheet worksheet = excel.Workbook.Worksheets[1];
                int            rowCount  = rowCount = worksheet.Dimension.Rows;

                for (int row = 6; row <= rowCount; row++)
                {
                    try
                    {
                        EmployeeViewModel      e = GetEmployeeViewModelByWorkSheet(worksheet, row);
                        PayslipDetailViewModel payslipDetailViewModel = GetPayslipDetailViewModelByWorkSheet(worksheet, row, requestId, e);

                        var      employee = _mapper.Map <EmployeeViewModel, Employee>(e);
                        Employee temp     = _employeeReponsitory.FindById(employee.Id);
                        if (temp == null)
                        {
                            _employeeReponsitory.Add(employee);
                        }
                        else
                        {
                            temp.Email    = employee.Email;
                            temp.FullName = employee.FullName;
                            temp.DeptTeam = employee.DeptTeam;
                            temp.StartDay = employee.StartDay;
                            temp.Position = employee.Position;
                        }
                        _employeeReponsitory.Commit();
                        var payslip = _mapper.Map <PayslipDetailViewModel, PayslipDetail>(payslipDetailViewModel);
                        _payslipDetailReponsitory.Add(payslip);
                        _payslipDetailReponsitory.Commit();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }