예제 #1
0
        public async Task OnGetAsync()
        {
            if (User.Identity.IsAuthenticated)
            {
                string emaiID = User.FindFirst(ClaimTypes.Email).Value;
                CurrentJobSeeker = await _jobseekerContext.JobSeekers.SingleOrDefaultAsync(m => (m.EmailID == emaiID));

                //industry field is being used for storing profile pic
                if (CurrentJobSeeker.Industry == null)
                {
                    CurrentJobSeeker.Industry = "images/profile-pic.png";
                }
                _jobseekerContext.JobSeekers.Update(CurrentJobSeeker);
                await _jobseekerContext.SaveChangesAsync();
            }
        }
예제 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            //try
            {
                if (User.Identity.IsAuthenticated)
                {
                    string AccountType = User.FindFirst(ClaimTypes.GivenName).Value;
                    if (AccountType == "JobSeeker")
                    {
                        string emaiID = User.FindFirst(ClaimTypes.Email).Value;
                        var    temp   = await _jobSeekerContext.JobSeekers.SingleOrDefaultAsync(m => (m.EmailID == emaiID));

                        var CurrentJob = await _jobContext.Jobs.SingleOrDefaultAsync(m => (m.ID == IDCurrent));

                        if (temp.AppliedJobs == null)
                        {
                            temp.AppliedJobs = "," + CurrentJob.ID.ToString();
                        }
                        else
                        {
                            temp.AppliedJobs = temp.AppliedJobs + "," + CurrentJob.ID.ToString();
                        }
                        if (CurrentJob.JobSeekersID == null)
                        {
                            CurrentJob.JobSeekersID = "," + temp.ID.ToString();
                        }
                        else
                        {
                            CurrentJob.JobSeekersID = CurrentJob.JobSeekersID + "," + temp.ID.ToString();
                        }
                        _jobContext.Jobs.Update(CurrentJob);
                        _jobSeekerContext.JobSeekers.Update(temp);
                        await _jobContext.SaveChangesAsync();

                        await _jobSeekerContext.SaveChangesAsync();

                        return(RedirectToPage("Index"));
                    }
                    else
                    {
                        return(Page());
                    }
                }
                else
                {
                    return(RedirectToPage("Index"));
                }
            }
            //catch(Exception)
            //{
            //    return RedirectToPage("/Error");
            //}
        }
예제 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                CurrentJobSeeker.EmailID = CurrentJobSeeker.EmailID.ToLower();
                var JobSeekers = await _jobseekerContext.JobSeekers.ToListAsync();

                foreach (var item in JobSeekers)
                {
                    if (item.EmailID == CurrentJobSeeker.EmailID)
                    {
                        ModelState.AddModelError(string.Empty, "Email Id Already Registered");
                        return(Page());
                    }
                }
                CurrentJobSeeker.AccountType = "JobSeeker";
                await _jobseekerContext.JobSeekers.AddAsync(CurrentJobSeeker);

                await _jobseekerContext.SaveChangesAsync();

                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, CurrentJobSeeker.FirstName + " " + CurrentJobSeeker.LastName),
                    new Claim(ClaimTypes.GivenName, "JobSeeker"),
                    new Claim(ClaimTypes.Email, CurrentJobSeeker.EmailID),
                };
                var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
                var authProperties = new AuthenticationProperties
                {
                    IsPersistent = true,
                    ExpiresUtc   = DateTimeOffset.UtcNow.AddMonths(1)
                };
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties);

                return(RedirectToPage("/JobSeekerEditProfile"));
            }
            else
            {
                return(Page());
            }
        }
예제 #4
0
        public async Task <IActionResult> OnPostAsync(IFormFile file)
        {
            if (file == null || file.Length == 0)
            {
                return(Content("file not selected"));
            }

            string emaiID   = User.FindFirst(ClaimTypes.Email).Value;
            var    tempUser = await _jobseekerContext.JobSeekers.SingleOrDefaultAsync(m => (m.EmailID == emaiID));

            var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", tempUser.ID.ToString() + file.FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await file.CopyToAsync(stream);
            }
            tempUser.Industry = "images/" + tempUser.ID.ToString() + file.FileName;
            _jobseekerContext.JobSeekers.Update(tempUser);
            await _jobseekerContext.SaveChangesAsync();

            return(RedirectToPage("/JobSeekerEditProfile"));
        }