public void SetActive(Guid SrfId, Guid CandidateId, int UserProfileId) { var Candidate = _contractor.GetAll().Where(x => x.Id.Equals(CandidateId) && x.AccountId.Equals(UserProfileId)).FirstOrDefault(); var CandidateSrf = _repository.GetAll().Where(x => x.CandidateId.Equals(Candidate.Id)).ToList(); var ApproveGeneral = _repository.GetSingle(SrfId); var ApproveEscalasi = _escalation.GetAll().Where(x => x.SrfId.Equals(SrfId)).FirstOrDefault(); if (CandidateSrf != null) { foreach (var srf in CandidateSrf) { var Temp = _repository.GetSingle(srf.Id); Temp.IsActive = false; Temp.IsLocked = true; _repository.Update(Temp); } if (ApproveGeneral != null || ApproveEscalasi != null) { var Srf = _repository.GetSingle(SrfId); Srf.IsActive = true; Srf.IsLocked = false; _repository.Update(Srf); } } }
private void Activation() { var AllSrf = _srf.GetAll().ToList(); var AllUser = _userProfile.GetAll().ToList(); var AllVacancy = _vacancy.GetAll().ToList(); var AllCandidate = _candidate.GetAll().ToList(); var AllEscalation = _escalation.GetAll().ToList(); var GetLastSrf = _srf.GetAll().OrderByDescending(x => x.CreatedAt).GroupBy(x => x.CandidateId).Select(x => x.Key).ToArray(); var SrfCandidate = _srf.GetAll().Where(x => GetLastSrf.Contains(x.CandidateId)).ToArray(); foreach (var srf in SrfCandidate) { // Set Active Srf To User var _temp = _srf.GetById(srf.Id); _temp.IsActive = true; // Set Terminate if (!string.IsNullOrEmpty(srf.TeriminateNote)) { var Candidate = _candidate.GetById(srf.CandidateId); if (Candidate.Account != null) { var pro = _userProfile.GetById(Candidate.AccountId); pro.IsBlacklist = false; pro.IsTerminate = true; _userProfile.Update(pro); } _temp.Status = SrfStatus.Terminate; } _srf.Update(_temp); } // Generate SRF NUMBER //foreach (var row in AllSrf) //{ // String SrfNumber = null; // if (string.IsNullOrEmpty(row.Number)) // { // SrfNumber = "0000"; // } // else // { // if (row.Number.Length > 4) // { // SrfNumber = row.Number.Substring(0, 4); // } // else // { // SrfNumber = row.Number; // } // } // var _temp = _srf.GetById(row.Id); // _temp.Number = SrfNumber; // _srf.Update(_temp); //} }
public SrfRequest GetCurrentSrfByLogin(ClaimsPrincipal user) { var UserProfile = GetLoginUser(user); var Candidate = _candidate.GetAll().Where(x => x.AccountId.Equals(UserProfile.Id)).FirstOrDefault(); var GetSrf = _srf.GetAll().Where(x => x.CandidateId.Equals(Candidate.Id) && x.IsActive == true).OrderByDescending(x => x.SrfEnd).FirstOrDefault(); if (GetSrf == null) { GetSrf = _srf.GetAll().Where(x => x.CandidateId.Equals(Candidate.Id)).OrderByDescending(x => x.SrfEnd).FirstOrDefault(); } return(GetSrf); }
public IActionResult CheckSrf() { var user = _userHelper.GetUser(User); var html = ""; if (user != null) { var Profile = _userProfileService.GetByUserId(user.Id); if (Profile == null) { html = "GAK PUNYA PROFILE"; } else { var CheckCandidate = _candidate.GetAll().Where(x => x.AccountId.Equals(Profile.Id)).FirstOrDefault(); if (CheckCandidate == null) { html = "GAK ADA DI CANDIDATE dengan PROFILE ID " + Profile.Id; } else { var SrfCheck = _srf.GetAll().Where(x => x.CandidateId.Equals(CheckCandidate.Id)).FirstOrDefault(); var Vacancy = _vacancy.GetById(CheckCandidate.VacancyId); if (SrfCheck == null) { html = "GAK ADA DI SRF dengan Candidate ID " + CheckCandidate.Id + " DAN VACANCY ID " + Vacancy.Id; } else { html = "ADA DI SRF dengan ID " + SrfCheck.Id + " DAN CANDIATE ID " + CheckCandidate.Id + " USER PROFILE " + Profile.Id + " DAN VACANCY ID " + CheckCandidate.VacancyId; } } } } else { html = "USER TIDAK DITEMUKAN"; } return(Content(html)); }
public JobStage GetByActiveUser(int UserId) { var CandidateInfo = _candidate .GetAll() .Where(x => x.AccountId == UserId) .OrderByDescending(x => x.CreatedAt) .FirstOrDefault(); if (CandidateInfo != null) { var Vacancy = _vacancy.GetById(CandidateInfo.VacancyId); return(_repository.GetSingle(Vacancy.JobStageId)); } return(null); }
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")); }
public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (!ModelState.IsValid) { return(View(model)); } var user = new ApplicationUser(); user = await userManager.FindByNameAsync(model.Username); if (user != null) { var UserProfile = _profile.GetByUserId(user.Id); if (UserProfile == null) { ModelState.AddModelError(string.Empty, "Your account is not registered"); return(View(model)); } else { // Checking Srf Status if (UserProfile.Roles.Trim().ToLower().Equals("Contractor".Trim().ToLower())) { var CheckCandidate = _candidate.GetAll().Where(x => x.AccountId.Equals(UserProfile.Id)).FirstOrDefault(); if (CheckCandidate == null) { ModelState.AddModelError(string.Empty, "You are not registered in Vacancy request."); return(View(model)); } else { var SrfCheck = _srf.GetAll().Where(x => x.CandidateId.Equals(CheckCandidate.Id)).FirstOrDefault(); if (SrfCheck == null) { ModelState.AddModelError(string.Empty, "You are not registered in SRF request."); return(View(model)); } } } } if (UserProfile.IsActive == false) { ModelState.AddModelError(string.Empty, "you account is closed by system"); return(View(model)); } else if (UserProfile.IsBlacklist == true) { ModelState.AddModelError(string.Empty, "you account is blacklist by system"); return(View(model)); } else if (UserProfile.IsTerminate == true) { ModelState.AddModelError(string.Empty, "you account is terminate by system"); return(View(model)); } else { if (!await userManager.IsEmailConfirmedAsync(user)) { ModelState.AddModelError("", "You must verify your account before proceeding. " + "Please check your email & follow the instruction."); return(View(model)); } var result = await signInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { return(RedirectToLocal(returnUrl)); } if (result.RequiresTwoFactor) { return(RedirectToAction(nameof(SendCode), new { returnUrl = returnUrl, RememberMe = model.RememberMe })); } if (result.IsLockedOut) { return(View("Lockout")); } else { await userManager.AccessFailedAsync(user); ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View(model)); } } } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View(model)); } }
public void Run() { // Create Candidate User int i = 0; List <string> Failed = new List <string>(); List <string> UserFailed = new List <string>(); List <string> IdExists = new List <string>(); var CandidateList = _candidate.GetAll().Where(x => x.Id == Guid.Parse("8934b42f-4818-472c-8e49-f808bf30be84")).OrderBy(x => x.Email).ToList(); foreach (var row in CandidateList) { var CheckEmail = _userManager.FindByEmailAsync(row.Email).Result; if (CheckEmail == null) { var UserProfile = new UserProfile(); UserProfile.Address = row.Address; UserProfile.Birthdate = row.DateOfBirth; UserProfile.Email = row.Email; UserProfile.Gender = row.Gender; UserProfile.HomePhoneNumber = row.HomePhoneNumber; if (row.IdNumber.Length > 16) { UserProfile.IdNumber = row.IdNumber.Substring(0, 15); } else { UserProfile.IdNumber = row.IdNumber; } UserProfile.IsActive = true; UserProfile.MobilePhoneNumber = row.MobilePhoneNumber; UserProfile.Name = row.Name; UserProfile.Roles = "Contractor"; UserProfile.UserName = "******"; UserProfile.IsBlacklist = false; UserProfile.IsTerminate = false; List <String> Role = new List <string>() { "Contractor" }; ApplicationUser NewUser = new ApplicationUser() { Email = row.Email, UserName = "******", UserProfile = UserProfile }; var created = _userManager.CreateAsync(NewUser, "welcome1!").Result; if (created.Succeeded) { var addRole = _userManager.AddToRolesAsync(NewUser, Role).Result; if (addRole.Succeeded) { Console.WriteLine(row.Email + " has been inserted"); //Console.WriteLine("A"); i++; } else { UserFailed.Add("'" + row.Email + "',"); Console.WriteLine(created.Errors.ToString()); //Console.WriteLine("B"); } } else { Failed.Add("'" + row.Id.ToString() + "',"); Console.WriteLine(created.Errors.ToString()); //Console.WriteLine("C"); } } else { UserFailed.Add("'" + row.Email + "',"); IdExists.Add(CheckEmail.Id); //Console.WriteLine("D"); } } Console.WriteLine("Total Insert " + i); if (Failed != null) { foreach (var row in Failed) { Console.WriteLine(row); } Console.WriteLine("================================"); foreach (var row in UserFailed) { Console.WriteLine(row); } Console.WriteLine("================================"); foreach (var row in IdExists) { Console.WriteLine("'" + row + "',"); } } }
public override IActionResult Edit(Guid id, AttendaceExceptionListModelForm model) { if (ModelState.IsValid) { var TimeSheetType = _timesheet.GetById(model.TimeSheetTypeId); var TempRecord = _attendanceRecord.GetAll().Where(x => x.AttendaceExceptionListId.Equals(id)).ToList(); if (TempRecord != null) { foreach (var row in TempRecord) { var Deleted = _attendanceRecord.GetById(row.Id); if (Deleted != null) { _attendanceRecord.Delete(Deleted); } } } var item = Service.GetById(id); if (item == null) { return(NotFound()); } var before = item; Mapper.Map(model, item); var CurrentUser = _userHelper.GetLoginUser(User); var Contractor = _contractor.GetAll().Where(x => x.AccountId.Equals(CurrentUser.Id)).FirstOrDefault(); if (Contractor.AccountId != null) { item.ContractorId = Contractor.AccountId; item.AgencyId = Contractor.AgencyId; item.RemainingDays = 0; item.LastEditedBy = _userHelper.GetUserId(User); item.LastUpdateTime = DateTime.Now; } if (!TimeSheetType.Type.ToLower().Trim().Equals("Annual leave".ToLower().Trim())) { if (!string.IsNullOrEmpty(model.Hours) && !string.IsNullOrEmpty(model.AttendanceRecordDate)) { var ListDate = model.AttendanceRecordDate.Split(','); item.DateStart = DateTime.Parse(ListDate[0]); item.DateEnd = DateTime.Parse(ListDate[ListDate.Length - 1]); } } Service.Update(item); AfterUpdateData(before, item); if (TimeSheetType.Type.ToLower().Trim().Equals("Annual leave".ToLower().Trim())) { double TotalDays = (((model.DateEnd - model.DateStart)).TotalDays) + 1; TotalDays = TotalDays < 1 ? 0 : TotalDays; for (int i = 1; i <= TotalDays; i++) { AttendanceRecord At = new AttendanceRecord() { AttendanceRecordDate = model.DateStart.AddDays(i), Hours = 8, AttendaceExceptionListId = item.Id }; _attendanceRecord.Add(At); } // Add Hours var Tempz = Service.GetById(item.Id); Tempz.OtherInfo = (8 * TotalDays).ToString(); Service.Update(Tempz); } else { if (!string.IsNullOrEmpty(model.Hours) && !string.IsNullOrEmpty(model.AttendanceRecordDate)) { var ListHours = model.Hours.Split(','); var ListDate = model.AttendanceRecordDate.Split(','); if (ListHours.Count() == ListHours.Count()) { int TotalHours = 0; for (int i = 0; i < ListHours.Count(); i++) { AttendanceRecord At = new AttendanceRecord() { AttendanceRecordDate = DateTime.Parse(ListDate[i]), Hours = int.Parse(ListHours[i]), AttendaceExceptionListId = item.Id }; _attendanceRecord.Add(At); TotalHours += int.Parse(ListHours[i]); } // Add Hours var Tempz = Service.GetById(item.Id); Tempz.OtherInfo = TotalHours.ToString(); Service.Update(Tempz); } } } TempData["Success"] = "Activity registration request has been updated"; return(RedirectToAction("Details", new { id })); } return(View(model)); }
protected override void CreateData(Claim item) { var UserLogin = _userHelper.GetLoginUser(User); var ContractorData = _candidate.GetAll().Where(x => x.AccountId.Equals(UserLogin.Id)).FirstOrDefault(); item.CreatedAt = DateTime.Now; item.CreatedBy = _userHelper.GetUserId(User); item.ClaimType = ClaimType.GeneralClaim; item.Contractor = _userHelper.GetLoginUser(User); item.StatusOne = StatusOne.Waiting; item.StatusTwo = StatusTwo.Waiting; item.ClaimStatus = ActiveStatus.Active; item.ClaimForId = null; item.DepartureId = null; item.DestinationId = null; item.RedeemForId = null; item.AddDate = DateTime.Now; if (ContractorData != null) { item.AgencyId = ContractorData.AgencyId; item.ContractorProfileId = ContractorData.Id; } var Category = _claimCategory.GetById(item.ClaimCategoryId); if (Category.Name.Trim().ToLower() == "Other Travel Allowance".Trim().ToLower()) { item.Domallo1 = 0; item.Domallo2 = 0; item.Domallo3 = 0; item.Domallo4 = 0; item.Domallo5 = 0; item.Domallo6 = 0; item.Intallo1 = 0; item.Intallo2 = 0; item.Intallo3 = 0; item.Intallo4 = 0; item.Intallo5 = 0; item.Intallo6 = 0; item.OnCallShift = 0; } else { if ( Category.Name.Trim().ToLower() == "On Call Allowance".Trim().ToLower() || Category.Name.Trim().ToLower() == "Shift Allowance".Trim().ToLower()) { item.Domallo1 = 0; item.Domallo2 = 0; item.Domallo3 = 0; item.Domallo4 = 0; item.Domallo5 = 0; item.Domallo6 = 0; item.Intallo1 = 0; item.Intallo2 = 0; item.Intallo3 = 0; item.Intallo4 = 0; item.Intallo5 = 0; item.Intallo6 = 0; } else { if (item.TripType == TripType.Domestic) { item.Intallo1 = 0; item.Intallo2 = 0; item.Intallo3 = 0; item.Intallo4 = 0; item.Intallo5 = 0; item.Intallo6 = 0; } else { item.Domallo1 = 0; item.Domallo2 = 0; item.Domallo3 = 0; item.Domallo4 = 0; item.Domallo5 = 0; item.Domallo6 = 0; } item.OnCallShift = 0; } } }