public IActionResult JobGiverSignUp(JobGiverLoginSignUpViewModel model) { var response = _authApiService.JobGiverSignUp(model.JobGiverSignUpModel); if (!response.Success) { HttpContext.Session.SetString("Alert", AlertifyHelper.ErrorMessage(response.Message)); return(RedirectToAction("JobGiverLoginSignUp")); } var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, model.JobGiverSignUpModel.Email), new Claim(ClaimTypes.Role, OperationClaimNames.Is_Veren) }, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); var login = HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); _tokenSessionHelper.SetToken(response.Data); HttpContext.Session.SetString("Alert", AlertifyHelper.SuccessMessage(Messages.SuccessRegister)); return(RedirectToAction("Index", "Home", new { area = "JobGiver" })); }
public IActionResult PostAJob(PostAJobViewModel model) { try { if (model.JobPostImage != null && model.JobPostImage.Length > 0) { #region base64string convert //try //{ // using (var ms = new MemoryStream()) // { // model.JobPostImage.CopyTo(ms); // var fileBytes = ms.ToArray(); // model.JobPostImageBase64 = Convert.ToBase64String(fileBytes); // // act on the Base64 data // } //} //catch //{ // model.JobFilterComponents = _homeApiService.GetHomeFilterComponents().Data; // model.GetSectorExperienceYearGenderDtos = _homeApiService.GetSectorExperienceYearGender().Data; // HttpContext.Session.SetString("Alert", AlertifyHelper.ErrorMessage(Messages.ErrorAddJobPost)); // return View(model); //} #endregion string uploadsFolder = Path.Combine(_env.WebRootPath, "jobimages"); string uniqueFileName = Guid.NewGuid().ToString() + "_" + model.JobPostImage.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { model.JobPostImage.CopyTo(fileStream); } model.JobPostImageUrl = "/jobimages/" + uniqueFileName; } if (model.ComponyLogo != null && model.ComponyLogo.Length > 0) { #region base64string convert //try //{ // using (var ms = new MemoryStream()) // { // model.ComponyLogo.CopyTo(ms); // var fileBytes = ms.ToArray(); // model.ComponyLogoBase64 = Convert.ToBase64String(fileBytes); // // act on the Base64 data // } //} //catch //{ // model.JobFilterComponents = _homeApiService.GetHomeFilterComponents().Data; // model.GetSectorExperienceYearGenderDtos = _homeApiService.GetSectorExperienceYearGender().Data; // HttpContext.Session.SetString("Alert", AlertifyHelper.ErrorMessage(Messages.ErrorAddJobPost)); // return View(model); //} #endregion string uploadsFolder = Path.Combine(_env.WebRootPath, "companyimages"); string uniqueFileName = Guid.NewGuid().ToString() + "_" + model.ComponyLogo.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { model.ComponyLogo.CopyTo(fileStream); } model.ComponyLogoUrl = "/companyimages/" + uniqueFileName; } } catch (Exception ex) { //todo: ex HttpContext.Session.SetString("Alert", AlertifyHelper.SuccessMessage(Messages.ErrorAddJobPost)); model.JobFilterComponents = _homeApiService.GetHomeFilterComponents().Data; model.GetSectorExperienceYearGenderDtos = _homeApiService.GetSectorExperienceYearGender().Data; return(View(model)); } model.JobDescription = HttpUtility.HtmlEncode(model.JobDescription); model.CompanyDescription = HttpUtility.HtmlEncode(model.CompanyDescription); PostAJobViewModelDto dto = _mapper.Map <PostAJobViewModelDto>(model); var response = _jobGiverJobPostApiService.JobGiverAddJobPostResponse(dto); if (response.Success) { HttpContext.Session.SetString("Alert", AlertifyHelper.SuccessMessage(Messages.SuccessAddJobPost)); } else { HttpContext.Session.SetString("Alert", AlertifyHelper.ErrorMessage(Messages.ErrorAddJobPost)); } model.JobFilterComponents = _homeApiService.GetHomeFilterComponents().Data; model.GetSectorExperienceYearGenderDtos = _homeApiService.GetSectorExperienceYearGender().Data; return(View(model)); }