public bool ImportNewUsers(ExcelPackage package)
        {
            ImportRepo importRepo = new ImportRepo();

            using (package)//ExcelPackage package = new ExcelPackage(new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "New_Staff.xlsx"))))
            {
                try
                {
                    ExcelWorksheet workSheet = package.Workbook.Worksheets[0];
                    int            totalRows = workSheet.Dimension.Rows;

                    DateTime today = DateTime.Today;

                    List <Staff> UserList = new List <Staff>();

                    for (int i = 2; i <= totalRows; i++)
                    {
                        if (workSheet.Cells[i, 7].Text != "")
                        {
                            //var dateInput = int.TryParse(workSheet.Cells[i, 10].Text.ToString(), out int n) ? workSheet.Cells[i, 10].Value.ToString() : workSheet.Cells[i, 10].Text.ToString();



                            //DateTime? dateValue = DateTimeExtensions.ParseDate(dateInput);

                            //if (dateValue == null)
                            //{
                            //    return false;

                            //}



                            var guid = Guid.NewGuid();

                            UserList.Add(new Staff
                            {
                                FirstName = string.IsNullOrEmpty(workSheet.Cells[i, 1].Text) ? null : workSheet.Cells[i, 1].Value.ToString(),
                                LastName  = string.IsNullOrEmpty(workSheet.Cells[i, 2].Text) ? null : workSheet.Cells[i, 2].Value.ToString(),

                                Gender       = string.IsNullOrEmpty(workSheet.Cells[i, 3].Text) ? null : workSheet.Cells[i, 3].Value.ToString(),
                                Nat          = string.IsNullOrEmpty(workSheet.Cells[i, 4].Text) ? null : workSheet.Cells[i, 4].Value.ToString(),
                                Nat2         = string.IsNullOrEmpty(workSheet.Cells[i, 5].Text) ? null : workSheet.Cells[i, 5].Value.ToString(),
                                SourceMarket = string.IsNullOrEmpty(workSheet.Cells[i, 6].Text) ? null : workSheet.Cells[i, 6].Value.ToString(),
                                Email        = string.IsNullOrEmpty(workSheet.Cells[i, 7].Text) ? null : workSheet.Cells[i, 7].Value.ToString(),
                                PhoneHome    = string.IsNullOrEmpty(workSheet.Cells[i, 8].Text) ? null : workSheet.Cells[i, 8].Value.ToString(),
                                AdCountry    = string.IsNullOrEmpty(workSheet.Cells[i, 9].Text) ? null : workSheet.Cells[i, 9].Value.ToString(),
                                Education    = string.IsNullOrEmpty(workSheet.Cells[i, 10].Text) ? null : workSheet.Cells[i, 10].Value.ToString(),
                                //DateOfBirth = dateInput,
                                DateOfBirth      = string.IsNullOrEmpty(workSheet.Cells[i, 11].Text) ? null : workSheet.Cells[i, 11].Value.ToString(),
                                Languages        = string.IsNullOrEmpty(workSheet.Cells[i, 12].Text) ? null : workSheet.Cells[i, 12].Value.ToString(),
                                Driver           = string.IsNullOrEmpty(workSheet.Cells[i, 13].Text) ? null : workSheet.Cells[i, 13].Value.ToString(),
                                DrivingYear      = string.IsNullOrEmpty(workSheet.Cells[i, 14].Text) ? null : workSheet.Cells[i, 14].Value.ToString(),
                                DateJoined       = string.IsNullOrEmpty(workSheet.Cells[i, 15].Text) ? null : workSheet.Cells[i, 15].Value.ToString(),
                                PositionType     = string.IsNullOrEmpty(workSheet.Cells[i, 16].Text) ? null : workSheet.Cells[i, 16].Value.ToString(),
                                LateStarterMonth = string.IsNullOrEmpty(workSheet.Cells[i, 17].Text) ? null : workSheet.Cells[i, 17].Value.ToString(),
                                StaffID          = guid.ToString(),
                                Status           = "New Recruit",
                                DateModified     = today
                            });
                        }
                    }

                    importRepo.ImportUsers(UserList);
                }
                catch (Exception e)
                {
                    Console.Write(e);
                }
            }
            return(true);
        }
        public bool ImportPositions(ExcelPackage package)
        {
            ImportRepo importRepo = new ImportRepo();

            try
            {
                using (package) //new ExcelPackage(new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "ImportPositions.xlsx"))))
                {
                    ExcelWorksheet     workSheet    = package.Workbook.Worksheets[0];
                    int                totalRows    = workSheet.Dimension.Rows;
                    DateTime           today        = DateTime.Today;
                    List <ImportModel> PositionList = new List <ImportModel>();


                    for (int i = 2; i <= totalRows; i++)
                    {
                        if (workSheet.Cells[i, 1].Text != "")
                        {
                            var dateInput = int.TryParse(workSheet.Cells[i, 19].Text.ToString(), out int n) ? workSheet.Cells[i, 19].Value.ToString() : workSheet.Cells[i, 19].Text.ToString();

                            var dateInput2 = int.TryParse(workSheet.Cells[i, 20].Text.ToString(), out int k) ? workSheet.Cells[i, 20].Value.ToString() : workSheet.Cells[i, 20].Text.ToString();

                            DateTime?dateValue = DateTimeExtensions.ParseDate(dateInput);

                            if (dateValue == null)
                            {
                                return(false);
                            }
                            DateTime?dateValue2 = DateTimeExtensions.ParseDate(dateInput2);


                            if (dateValue2 == null)
                            {
                                return(false);
                            }



                            PositionList.Add(new ImportModel
                            {
                                MPLID           = Convert.ToInt32(workSheet.Cells[i, 1].Value),
                                Season          = string.IsNullOrEmpty(workSheet.Cells[i, 2].Text) ? null : workSheet.Cells[i, 2].Value.ToString(),
                                Region          = string.IsNullOrEmpty(workSheet.Cells[i, 3].Text) ? null : workSheet.Cells[i, 3].Value.ToString(),
                                Country         = string.IsNullOrEmpty(workSheet.Cells[i, 4].Text) ? null : workSheet.Cells[i, 4].Value.ToString(),
                                HeadOf          = string.IsNullOrEmpty(workSheet.Cells[i, 5].Text) ? null : workSheet.Cells[i, 5].Value.ToString(),
                                SDD_DM          = string.IsNullOrEmpty(workSheet.Cells[i, 6].Text) ? null : workSheet.Cells[i, 6].Value.ToString(),
                                Destination     = string.IsNullOrEmpty(workSheet.Cells[i, 7].Text) ? null : workSheet.Cells[i, 7].Value.ToString(),
                                IATACode        = string.IsNullOrEmpty(workSheet.Cells[i, 8].Text) ? null : workSheet.Cells[i, 8].Value.ToString(),
                                ConceptHotel    = string.IsNullOrEmpty(workSheet.Cells[i, 9].Text) ? null : workSheet.Cells[i, 9].Value.ToString(),
                                JobFamily       = string.IsNullOrEmpty(workSheet.Cells[i, 10].Text) ? null : workSheet.Cells[i, 10].Value.ToString(),
                                JobTitle        = string.IsNullOrEmpty(workSheet.Cells[i, 11].Text) ? null : workSheet.Cells[i, 11].Value.ToString(),
                                Profile         = string.IsNullOrEmpty(workSheet.Cells[i, 12].Text) ? null : workSheet.Cells[i, 12].Value.ToString(),
                                MPL_DL_Required = string.IsNullOrEmpty(workSheet.Cells[i, 13].Text) ? null : workSheet.Cells[i, 13].Value.ToString(),
                                MPLPositionType = string.IsNullOrEmpty(workSheet.Cells[i, 14].Text) ? null : workSheet.Cells[i, 14].Value.ToString(),
                                ProcentWorkTime = string.IsNullOrEmpty(workSheet.Cells[i, 15].Text) ? null : workSheet.Cells[i, 15].Value.ToString(),
                                MPLSourceMarket = string.IsNullOrEmpty(workSheet.Cells[i, 16].Text) ? null : workSheet.Cells[i, 16].Value.ToString(),
                                Languages       = string.IsNullOrEmpty(workSheet.Cells[i, 17].Text) ? null : workSheet.Cells[i, 17].Value.ToString(),
                                HighSeason      = string.IsNullOrEmpty(workSheet.Cells[i, 18].Text) ? null : workSheet.Cells[i, 18].Value.ToString(),

                                PositionStartDate = dateValue,
                                PositionEndDate   = dateValue2,


                                MPLDateCreated  = string.IsNullOrEmpty(workSheet.Cells[i, 21].Text) ? null : workSheet.Cells[i, 21].Value.ToString(),
                                FTE             = string.IsNullOrEmpty(workSheet.Cells[i, 22].Text) ? null : workSheet.Cells[i, 22].Value.ToString(),
                                MPLDateModified = string.IsNullOrEmpty(workSheet.Cells[i, 23].Text) ? null : workSheet.Cells[i, 23].Value.ToString(),

                                DateModified = today
                            });
                        }
                        importRepo.ImportPosistions(PositionList);
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
                return(false);
            }
        }
 public MasterImportController(IConfiguration configuration)
 {
     _configuration = configuration;
     iRepo          = new ImportRepo(configuration);
 }