public async Task <IActionResult> CandidatesAsync(long id) { List <CandidateViewModel> model = new List <CandidateViewModel>(); IEnumerable <JobApply> jobapplies = _jobApplyRepository.Find(x => x.JobID == id); foreach (var jobapply in jobapplies) { string address1 = ""; ApplicationUser appuser = await _userManager.FindByIdAsync(jobapply.UserID); var jobseeker = _jobseekerRepository.FindByAsyn(x => x.ApplicationUserId == appuser.Id).Result.FirstOrDefault(); CandidateViewModel candidate = new CandidateViewModel(); var postalCodeDetail = _postalCodeRepository.GetPostalCodeDetail(jobseeker.PostalAddrss); if (postalCodeDetail != null) { var province = _provinceRepository.GetById(postalCodeDetail.ProvinceID); if (province != null) { address1 = postalCodeDetail.Code + " " + province.Name_Jp + " " + postalCodeDetail.CityName + " " + postalCodeDetail.CityName; } } candidate.Name = jobseeker.LastName + " " + jobseeker.FirstName; candidate.EmailAddress = appuser.Email; candidate.AppliedDate = jobapply.ApplyDate; candidate.Address = address1 + " " + jobseeker.Address; candidate.ContactNumber = appuser.PhoneNumber; model.Add(candidate); } return(View(model)); }
public async Task <IActionResult> UploadAsync(List <IFormFile> files) { IList <Job> jobList = new List <Job>(); try { long size = files.Sum(f => f.Length); if (size > 0) { foreach (var formFile in files) { Stream fileStream = formFile.OpenReadStream(); DataTable clientData = await _importService.ImportExcelAsync(fileStream); //End of testing code foreach (DataRow dr in clientData.Rows) { Job model = new Job(); if (dr["Client_Id"] == null || dr["Client_Id"].ToString().Trim() == "") { throw new Exception("Client Id can't be null"); } int clientsId = Convert.ToInt32(dr["Client_Id"]); var client = _clientRepository.GetById(Convert.ToInt32(dr["Client_Id"] ?? 0)); model.Client = client ?? throw new Exception($"client {clientsId} do not exists"); model.CompanyName = client.CompanyName; model.ContractType_Text = Convert.ToString(dr["Contract_Type"]); model.NeededStaff = Convert.ToString(dr["Needed_Staff"]); model.Role = Convert.ToString(dr["Role"]); model.Salary_Monthly = Convert.ToString(dr["Salary_Monthly"]); model.Salary_Hourly = Convert.ToString(dr["Salary_Hourly"]); if (dr["Is_Trasporation_Include"] == null || dr["Is_Trasporation_Include"].ToString().Trim() == "") { throw new Exception("Transporation_Include value can't null"); } model.TrasportationIncluded = Convert.ToChar(dr["Is_Trasporation_Include"]); model.Transporationfee = Convert.ToString(dr["Transporation_Fee_Max"]); model.WorkingdaysPerweek = Convert.ToString(dr["Working_Days_Per_Week"]); model.Workinghour = Convert.ToString(dr["Working_Hours_Per_Day"]); if (dr["Postal_Code"] == null || dr["Postal_Code"].ToString().Trim() == "") { throw new Exception("Postal Code value can't be null"); } string postalcodestr = Convert.ToString(dr["Postal_Code"]); var postalCode = _postalCodeRepository.GetPostalCodeDetail(Convert.ToString(dr["Postal_Code"])); model.PostalCode = postalCode ?? throw new Exception($"Postal Code {postalcodestr} do not exists"); model.provinceName = Convert.ToString(dr["Prefrecture"]); if (dr["Job_Category_Id"] == null || dr["Job_Category_Id"].ToString().Trim() == "") { throw new Exception("Job Category can't be null"); } int jobcategoryId = Convert.ToInt32(dr["Job_Category_Id"]); var jobCategory = _jobCategoryRepository.GetById(Convert.ToInt32(dr["Job_Category_Id"])); model.JobCategory = jobCategory ?? throw new Exception($"jobcategory {jobcategoryId} do not exists");; model.JobTitle = jobCategory.CategoryName; if (dr["Status"] == null || dr["Status"].ToString().Trim() == "") { throw new Exception("Status value should have 0 or 1"); } model.Status = Convert.ToBoolean(dr["Status"].ToString() == "1" ? 1 : 0); model.BusinessStreamID = Convert.ToInt32(dr["Business_Stream_Id"]); model.JapaneseLevel_Text = Convert.ToString(dr["Japanese_Level"]); // model.JobTitle_JP = Convert.ToString(dr["Job_Title_JP"]); model.WorkLocationAddress = Convert.ToString(dr["Job_Address"]); model.PostDate = DateTime.Now; model.JapaneseLevel = new JapaneseLevel(); model.ContractType = new ContractType(); jobList.Add(model); } await _jobsRepository.AddListAsyn(jobList); await _jobsRepository.SaveAsync(); TempData["success"] = "Successfully Uploaded"; } } else { TempData["error"] = "Please browse excel file (format .xls,.xlsx) to upload and then click on upload button"; } } catch (Exception ex) { TempData["error"] = ex.Message; } return(RedirectToAction("IndexAsync")); }
public async Task <IActionResult> Index() { var user = await _userManager.GetUserAsync(User); var jobseeker = _jobSeekerRepository.GetJobSeekerByUserId(user.Id); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } string areaCode = ""; string postalCode = ""; string city = ""; string town = ""; int.TryParse(jobseeker.BirthYear, out int birthYear); int.TryParse(jobseeker.BirthMonth, out int birthMonth); int.TryParse(jobseeker.BirthDay, out int birthDay); int age = 0; if (birthYear != 0 && birthMonth != 0 && birthDay != 0) { DateTime dob = new DateTime(birthYear, birthMonth, birthDay); age = _autoFillService.CalculateYourAge(dob); } if (jobseeker.PostalAddrss != "-" && jobseeker.PostalAddrss != "") { var postal = _postalCodeRepository.GetPostalCodeDetail(jobseeker.PostalAddrss); string[] postalArry = jobseeker.PostalAddrss.Split("-"); areaCode = postalArry[0]; postalCode = postalArry[1]; city = postal.CityName_En; town = postal.Town_En; } else { city = jobseeker.City; town = jobseeker.Town; } //Get visa Parent Id string phoneNumber = user.PhoneNumber; if (string.IsNullOrWhiteSpace(phoneNumber)) { phoneNumber = ""; } var model = new EditUserViewModel { FirstName = jobseeker.FirstName, LastName = jobseeker.LastName, BirthYear = jobseeker.BirthYear, BirthMonth = jobseeker.BirthMonth, BirthDay = jobseeker.BirthDay, Email = user.Email, PhoneNumber = phoneNumber.Replace("+", "").Replace("-", ""), ProvinceID = jobseeker.Province.Id, PostalAddrss1 = areaCode, PostalAddrss2 = postalCode, CityName = city, Town = town, CountryID = jobseeker.CountryID, VisaTypeParentId = jobseeker.VisaCategory.ParentId, Age = age == 0 ? "" : age.ToString(), Address = jobseeker.Address }; model.Countries = await _autoFillService.AddCountryListAsync(); model.Provinces = await _autoFillService.AddProvinceListAsync(); model.VisaTypes = _autoFillService.AddVisaList(); return(View(model)); }
public async Task <IActionResult> AddClientAsync(AddClientViewModel model) { model.Provinces = await _autoFillService.AddProvinceListAsync(); if (ModelState.IsValid) { var postaladdress = model.PostalAddrss1 + "-" + model.PostalAddrss2; PostalCode postalcode = _postalCodeRepository.GetPostalCodeDetail(postaladdress); var client = new Client { CompanyName = model.CompanyName, ContactEmail = model.ContactEmail, ContactPerson = model.ContactPerson, ContactNumber = model.ContactNumber, WebsiteUrl = model.WebsiteUrl, BusinessstreamID = model.BusinessstreamID, Address = model.Address, AboutCompany = model.AboutCompany, PostalCode = postalcode, Status = 'I' }; //Guid guid = Guid.NewGuid(); string username = model.ContactEmail; //string password = guid.ToString().Split('-')[1] + DateTime.Now.Date.ToString("yyyyMdd"); var appUser = new ApplicationUser { FirstName = model.FirstName, LastName = model.LastName, UserName = username, Email = model.ContactEmail, PhoneNumber = model.ContactNumber, CreateDate = DateTime.Now }; if (!_roleManager.RoleExistsAsync("client").Result) { await _roleManager.CreateAsync(new IdentityRole("client")); } var result = await _userManager.CreateAsync(appUser); if (result.Succeeded) { //client.ApplicationUser = appUser; var roleRegister = _userManager.AddToRoleAsync(appUser, "client").Result; } else { AddErrors(result); return(View(model)); } //_clientRepository.Create(client); await _clientRepository.AddAsyn(client); var companyclientmap = new CompanyUser { Client = client, ApplicationUser = appUser }; await _clientRepository.SaveAsync(); _companyUsersRepository.Create(companyclientmap); if (model.Files != null) { //string webrootpath = _hostingEnvironment.WebRootPath; string folderpath = Path.Combine(_hostingEnvironment.WebRootPath, "assets", "img", "companies", client.Id.ToString()); string virtualPath = Path.Combine("..", "assets", "img", "companies", client.Id.ToString()); if (!Directory.Exists(folderpath)) { Directory.CreateDirectory(folderpath); } string filePath = Path.Combine(folderpath, $"companyimage.png"); string virtualFilePath = Path.Combine(virtualPath, $"companyimage.png"); using (Image img = Image.FromStream(model.Files[0].OpenReadStream())) { var resizedImg = img.Resize(250, 250); resizedImg.SaveIntoDisk(filePath); //save image path into comapnyimage object CompanyImage companyImage = new CompanyImage(); companyImage.ImagePath = virtualFilePath; companyImage.Client = client; await _companyImage.AddAsyn(companyImage); await _companyImage.SaveAsync(); } } return(Redirect("~/Admin")); } else { return(View(model)); } }