Exemplo n.º 1
0
        public override IActionResult Edit(string id, RecoveryForm model)
        {
            if (ModelState.IsValid)
            {
                var User = _userHelper.GetUser(id);
                if (User != null)
                {
                    // Insert Vacancy
                    var NewVacancy = new VacancyList();
                    NewVacancy.AccountNameId         = model.AccountNameId;
                    NewVacancy.ApproverOneId         = model.ApproverOneId;
                    NewVacancy.ApproverTwoId         = model.SourcingId;
                    NewVacancy.CostCodeId            = model.CostCodeId;
                    NewVacancy.CreatedAt             = DateTime.Now;
                    NewVacancy.DepartmentId          = model.DepartmentId;
                    NewVacancy.DepartmentSubId       = model.DepartmentSubId;
                    NewVacancy.JobStageId            = model.JobStageId;
                    NewVacancy.JoinDate              = model.JoinDate;
                    NewVacancy.NetworkId             = model.NetworkId;
                    NewVacancy.NoarmalRate           = model.NoarmalRate;
                    NewVacancy.OtLevel               = model.OtLevel;
                    NewVacancy.RequestBy             = _userHelper.GetUserProfile(model.ApproverOneId);
                    NewVacancy.PackageTypeId         = model.PackageTypeId;
                    NewVacancy.ServicePackCategoryId = model.ServicePackCategoryId;
                    NewVacancy.ServicePackId         = model.ServicePackId;
                    //NewVacancy.Status = VacanStatusFive.Done;
                    NewVacancy.VacancyStatus = ApproverStatus.Completed;
                    NewVacancy.isHrms        = model.isHrms;
                    NewVacancy.isLaptop      = model.isLaptop == 1 ? true : false;
                    NewVacancy.isManager     = model.isManager;
                    NewVacancy.isUsim        = model.isUsim;
                    NewVacancy.StatusOne     = SrfApproveStatus.Approved;
                    NewVacancy.StatusTwo     = SrfApproveStatus.Approved;
                    NewVacancy.StatusThree   = SrfApproveStatus.Approved;
                    NewVacancy.StatusFourth  = SrfApproveStatus.Approved;
                    _vacancy.Add(NewVacancy);

                    if (NewVacancy.Id != null)
                    {
                        // Insert Candidate
                        var UserProfile  = _profileService.GetByUserId(id);
                        var GetCandidate = _candidate.GetAll().Where(x => x.AccountId == UserProfile.Id).FirstOrDefault();

                        if (GetCandidate == null)
                        {
                            var Candidate = new CandidateInfo();
                            Candidate.Account           = UserProfile;
                            Candidate.Address           = UserProfile.Address;
                            Candidate.AgencyId          = model.AgencyId;
                            Candidate.AgencyType        = AgencyType.Agency;
                            Candidate.ApproveOneDate    = DateTime.Now;
                            Candidate.ApproveOneStatus  = ApproverStatus.Selected;
                            Candidate.ApproveTwoeDate   = DateTime.Now;
                            Candidate.CreatedAt         = DateTime.Now;
                            Candidate.Email             = User.Email;
                            Candidate.Gender            = UserProfile.Gender.Value;
                            Candidate.HomePhoneNumber   = UserProfile.HomePhoneNumber;
                            Candidate.IdNumber          = UserProfile.IdNumber;
                            Candidate.IsCandidate       = false;
                            Candidate.IsContractor      = true;
                            Candidate.IsUser            = true;
                            Candidate.Martial           = Martial.M1;
                            Candidate.MobilePhoneNumber = UserProfile.MobilePhoneNumber;
                            Candidate.Name             = UserProfile.Name;
                            Candidate.Nationality      = "Indonesia";
                            Candidate.NickName         = UserProfile.Name;
                            Candidate.PlaceOfBirth     = UserProfile.Birthplace;
                            Candidate.DateOfBirth      = UserProfile.Birthdate.Value;
                            Candidate.RequestBy        = _userHelper.GetUserProfile(model.AgencyId);
                            Candidate.ApproveTwoStatus = ApproverStatus.Completed;
                            Candidate.Vacancy          = NewVacancy;
                            GetCandidate = _candidate.Add(Candidate);
                        }

                        if (GetCandidate != null)
                        {
                            var Department = _department.GetById(model.DepartmentId);
                            var Network    = _network.GetById(model.NetworkId);
                            // Insert SRF
                            SrfRequest NewSrf = new SrfRequest();
                            NewSrf.CreatedAt          = DateTime.Now;
                            NewSrf.Number             = "0000";
                            NewSrf.Type               = SrfType.New;
                            NewSrf.ApproveStatusOne   = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusTwo   = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusThree = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusFour  = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusFive  = SrfApproveStatus.Approved;
                            NewSrf.ApproveStatusSix   = SrfApproveStatus.Approved;
                            NewSrf.RequestBy          = _userHelper.GetUserProfile(model.ApproverOneId).Name;
                            NewSrf.SrfBegin           = model.SrfBegin;
                            NewSrf.SrfEnd             = model.SrfEnd;
                            NewSrf.ServiceLevel       = model.OtLevel;
                            NewSrf.isWorkstation      = model.isLaptop == 1 ? true  : false;
                            NewSrf.isCommunication    = model.isUsim;
                            NewSrf.IsHrms             = model.isHrms;
                            NewSrf.IsOps              = Department.OperateOrNon == 1 ? true : false;
                            NewSrf.IsManager          = false;
                            NewSrf.RateType           = Domain.Models.Enum.RateType.Normal;
                            NewSrf.IsExtended         = false;
                            NewSrf.IsLocked           = false;
                            NewSrf.Status             = Domain.Models.Enum.SrfStatus.Done;
                            NewSrf.SpectValue         = 0;
                            NewSrf.IsActive           = false;
                            NewSrf.ServicePackId      = model.ServicePackId;
                            NewSrf.NetworkId          = model.NetworkId;
                            NewSrf.CostCenterId       = model.CostCodeId;
                            NewSrf.LineManagerId      = model.ApproverOneId;
                            NewSrf.ActivityCode       = _activity.GetAll().OrderBy(x => Guid.NewGuid()).FirstOrDefault();
                            NewSrf.DepartmentId       = model.DepartmentId;
                            NewSrf.DepartmentSubId    = model.DepartmentSubId;
                            NewSrf.ProjectManagerId   = Network.ProjectManagerId;
                            NewSrf.ApproveOneId       = model.ApproverOneId;
                            NewSrf.ApproveTwoId       = model.ApproveTwoId;
                            NewSrf.ApproveThreeId     = model.ApproveThreeId;
                            NewSrf.ApproveFourId      = model.ApproveFourId;
                            NewSrf.ApproveSixId       = model.ApproveSixId;
                            NewSrf.Candidate          = GetCandidate;
                            NewSrf.AccountId          = model.AccountNameId;
                            NewSrf.IsLocked           = false;
                            NewSrf.IsActive           = true;
                            var AnnualLeave = MonthDistance(model.SrfBegin, model.SrfEnd);
                            NewSrf.AnnualLeave = AnnualLeave;
                            Service.Add(NewSrf);
                            if (NewSrf.Id != null)
                            {
                                TempData["Success"] = true;
                            }
                        }
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        private void VacancyAndCandidate()
        {
            Data dt = new Data("vacany_candidate");

            foreach (var row in dt.GetData())
            {
                int index   = 1;
                var Data    = (List <String>)row;
                var Org     = _department.GetAll().Where(x => Truncate(x.Name) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var SubOrg  = _departmentSub.GetAll().Where(x => Truncate(x.SubName) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var CostCr  = _costCenter.GetAll().Where(x => Truncate(x.Code) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var AnnName = _account.GetAll().Where(x => Truncate(x.Name) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var Net     = _networkNumber.GetAll().Where(x => Truncate(x.Code) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                if (Net == null)
                {
                    Net = _networkNumber.GetAll().OrderBy(x => Guid.NewGuid()).FirstOrDefault();
                }
                var JoinDate         = DateTime.Parse(Data[index].ToString()); index += 1;
                var PackageType      = _packageType.GetAll().Where(x => Truncate(x.Name) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var SsowCategory     = _ssow_category.GetAll().Where(x => Truncate(x.Name) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var Ssow             = _ssow.GetAll().Where(x => Truncate(x.Name) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var BasiServiceLevel = int.Parse(Data[index].ToString()); index += 1;
                var IsWorkstation    = int.Parse(Data[index].ToString()); index += 1;
                var IsUsim           = int.Parse(Data[index].ToString()); index += 1;
                var IsManager        = int.Parse(Data[index].ToString()); index += 1;
                var NormalRate       = int.Parse(Data[index].ToString()); index += 1;
                var IsSignum         = int.Parse(Data[index].ToString()); index += 1;
                var Jobstage         = _jobstage.GetAll().Where(x => Truncate(x.Stage) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var LineManager      = _userProfile.GetAll().Where(x => Truncate(x.Name) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;
                var Sourcing         = _userProfile.GetAll().Where(x => Truncate(x.Email) == Truncate(Data[index].ToString())).FirstOrDefault(); index += 1;

                var NewVacancy = new VacancyList();
                NewVacancy.AccountName         = AnnName;
                NewVacancy.ApproverOne         = LineManager;
                NewVacancy.ApproverTwo         = Sourcing;
                NewVacancy.CostCenter          = CostCr;
                NewVacancy.CreatedAt           = JoinDate;
                NewVacancy.Departement         = Org;
                NewVacancy.DepartementSub      = SubOrg;
                NewVacancy.JobStage            = Jobstage;
                NewVacancy.JoinDate            = JoinDate;
                NewVacancy.Network             = Net;
                NewVacancy.NoarmalRate         = NormalRate;
                NewVacancy.OtLevel             = BasiServiceLevel;
                NewVacancy.RequestBy           = LineManager;
                NewVacancy.PackageType         = PackageType;
                NewVacancy.ServicePackCategory = SsowCategory;
                NewVacancy.ServicePack         = Ssow;
                NewVacancy.Status        = VacanStatusFive.Done;
                NewVacancy.VacancyStatus = ApproverStatus.Completed;
                NewVacancy.isHrms        = IsSignum == 1 ? true : false;
                NewVacancy.isLaptop      = IsWorkstation == 1 ? true : false;
                NewVacancy.isManager     = IsManager == 1 ? true : false;
                NewVacancy.isUsim        = IsUsim == 1 ? true : false;
                NewVacancy.StatusOne     = VacanStatusFirst.Selected;
                NewVacancy.StatusTwo     = VacanStatusSecond.Approved;
                NewVacancy.StatusThree   = VacanStatusThirth.Done;
                NewVacancy.StatusFourth  = VacanStatusFourth.Approved;

                var AgencyType    = int.Parse(Data[index].ToString()); index += 1;
                var CandidateName = Data[index].ToString(); index += 1;
                var NickName      = Data[index].ToString(); index += 1;
                var Email         = Data[index].ToString(); index += 1;
                var IdNumber      = Data[index].ToString(); index += 1;
                if (IdNumber.Length > 16)
                {
                    IdNumber = IdNumber.Substring(0, 16);
                }
                var Nationality  = Data[index].ToString(); index += 1;
                var PlaceOfBirth = Data[index].ToString(); index += 1;
                var DateOfBirth  = DateTime.Parse(Data[index].ToString()); index += 1;
                var Address      = Data[index].ToString(); index += 1;
                var Gender       = Data[index].ToString(); index += 1;
                var Martial      = Data[index].ToString(); index += 1;
                var PhoneNMobile = Data[index].ToString(); index += 1;
                var PhoneHome    = Data[index].ToString(); index += 1;
                var Description  = Data[index].ToString(); index += 1;
                var HomeBase     = Data[index].ToString(); index += 1;
                var AhId         = Data[index].ToString(); index += 1;
                var FormEricsson = int.Parse(Data[index].ToString()); index += 1;
                var Agency       = Data[index].ToString();

                var UserCurrent = _userManager.FindByEmailAsync(Email).Result;
                if (UserCurrent != null)
                {
                    var delete = _userManager.DeleteAsync(UserCurrent).Result;
                }

                var UserAgency  = _userProfile.GetAll().Where(x => Truncate(x.Email) == Truncate(Agency)).FirstOrDefault();
                var UserProfile = new UserProfile();
                UserProfile.Address           = Address;
                UserProfile.Birthdate         = DateOfBirth;
                UserProfile.Email             = Email;
                UserProfile.Gender            = Gender.Equals(Truncate("F")) ? Domain.Models.Enum.Gender.Female : Domain.Models.Enum.Gender.Male;
                UserProfile.HomePhoneNumber   = PhoneHome;
                UserProfile.IdNumber          = IdNumber;
                UserProfile.IsActive          = true;
                UserProfile.MobilePhoneNumber = PhoneNMobile;
                UserProfile.Name        = CandidateName;
                UserProfile.Roles       = "Contractor";
                UserProfile.UserName    = Email;
                UserProfile.IsBlacklist = false;
                UserProfile.IsTerminate = false;
                UserProfile.AhId        = AhId;

                List <String> Role = new List <string>()
                {
                    "Contractor"
                };
                ApplicationUser NewUser = new ApplicationUser()
                {
                    Email       = Email,
                    UserName    = Email,
                    UserProfile = UserProfile
                };
                var created = _userManager.CreateAsync(NewUser, "welcome1!").Result;
                if (created.Succeeded)
                {
                    var addRole = _userManager.AddToRolesAsync(NewUser, Role).Result;
                    if (addRole.Succeeded)
                    {
                        _vacancy.Add(NewVacancy);

                        var code      = _userManager.GenerateEmailConfirmationTokenAsync(NewUser).Result;
                        var Succseed  = _userManager.ConfirmEmailAsync(NewUser, code).Result;
                        var Candidate = new CandidateInfo();
                        Candidate.Account           = NewUser.UserProfile;
                        Candidate.Address           = Address;
                        Candidate.Agency            = UserAgency;
                        Candidate.AgencyType        = (AgencyType)AgencyType;
                        Candidate.ApproveOneDate    = JoinDate;
                        Candidate.ApproveOneStatus  = ApproverStatus.Selected;
                        Candidate.ApproveTwoeDate   = JoinDate;
                        Candidate.CreatedAt         = JoinDate;
                        Candidate.Email             = Email;
                        Candidate.Gender            = Gender.Equals(Truncate("F")) ? Domain.Models.Enum.Gender.Female : Domain.Models.Enum.Gender.Male;
                        Candidate.HomePhoneNumber   = PhoneNMobile;
                        Candidate.IdNumber          = IdNumber;
                        Candidate.IsCandidate       = false;
                        Candidate.IsContractor      = true;
                        Candidate.IsUser            = true;
                        Candidate.Martial           = (Martial)Enum.Parse(typeof(Martial), Martial, true);
                        Candidate.MobilePhoneNumber = PhoneNMobile;
                        Candidate.Name             = CandidateName;
                        Candidate.Nationality      = Nationality;
                        Candidate.NickName         = NickName;
                        Candidate.PlaceOfBirth     = PlaceOfBirth;
                        Candidate.DateOfBirth      = DateOfBirth;
                        Candidate.RequestBy        = UserAgency;
                        Candidate.ApproveTwoStatus = ApproverStatus.Completed;
                        Candidate.Vacancy          = NewVacancy;
                        _candidate.Add(Candidate);

                        if (Candidate != null)
                        {
                            Console.WriteLine(Email + " has been added ");
                        }

                        Count++;
                    }
                }
            }
            Console.WriteLine(Count + " Candidate record has been saved ");
        }