public async Task <IActionResult> AddClientAsync() { AddClientViewModel model = new AddClientViewModel(); model.Provinces = await _autoFillService.AddProvinceListAsync(); //if (model.businessstreams.Count == 0) //{ // model.businessstreams = new List<SelectListItem>(); // model.businessstreams.Add(new SelectListItem // { // Value = "", // Text = "-- Choose Industry --" // }); // var businessstreams = _businessRepository.GetAll(); // foreach (var BusinessStrem in businessstreams) // { // model.businessstreams.Add(new SelectListItem // { // Value = Convert.ToString(BusinessStrem.Id), // Text = BusinessStrem.Name // }); // } //} //if (model.Provinces.Count == 0) //{ // model.Provinces = new List<SelectListItem>(); // model.Provinces.Add(new SelectListItem // { // Value = "", // Text = "--Choose--" // }); // var provinces = _provinceRepository.GetAll(); // foreach (var province in provinces) // { // model.Provinces.Add(new SelectListItem // { // Value = Convert.ToString(province.Id), // Text = province.Name // }); // } //} return(View(model)); }
public async Task <IActionResult> EditProfile() { var model = new ClientEditViewModel(); var user = await _userManager.GetUserAsync(HttpContext.User); var userId = _userManager.GetUserId(HttpContext.User); var username = _userManager.GetUserName(HttpContext.User); if (userId != null) { var client = _clientRepository.GetClientByUserId(userId); model.Provinces = await _autoFillService.AddProvinceListAsync(); model.FirstName = user.FirstName; model.PhoneNumber = user.PhoneNumber; model.LastName = user.LastName; model.ClientID = client.Id; model.CompanyName = client.CompanyName; //model.ContactPerson = client.ContactPerson; model.ClientID = client.Id; model.UserName = username; model.WebsiteUrl = client.WebsiteUrl; model.ContactPerson = client.ContactPerson; //model.PhoneNumber = client.ContactNumber; model.BusinessStreamID = client.BusinessstreamID; PostalCode postalcode = _postalCodeRepository.GetById(client.PostalCodeID); string[] postalcodeArry = postalcode.Code.Split("-"); if (postalcodeArry.Count() > 0) { model.PostalAddrss1 = postalcodeArry[0]; model.PostalAddrss2 = postalcodeArry[1]; } model.ProvinceID = postalcode.ProvinceID; model.Address = client.Address; model.CityName = client.PostalCode.CityName; model.Town = client.PostalCode.Town; //} } return(View(model)); }
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)); }