// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Job).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobExists(Job.JobId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Job = await _context.Job.FindAsync(id); if (Job != null) { _context.Job.Remove(Job); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostCvAsync() { if (!ModelState.IsValid) { Message = "CV is required!"; ModelState.AddModelError("", "CV is required"); } else { var job = Job.JobId; var user = await userManager.FindByNameAsync(User.Identity.Name); var userJob = _context.UserJob.Where(x => x.JobId == job).AsNoTracking().ToList(); var result = userJob.FirstOrDefault(x => x.UserId == user.Id); if (result == null) { var file = Path.Combine(env.ContentRootPath, "uploads", Cv.FileName); using (var fileStream = new FileStream(file, FileMode.Create)) { await Cv.CopyToAsync(fileStream); var path = fileStream.Name.ToString(); var vm = new UserJob { UserId = user.Id, CV_Url = path, JobId = job }; _context.UserJob.Add(vm); await _context.SaveChangesAsync(); } Message = "Applied Successfuly"; return(RedirectToPage("./Index")); } else { Message = "You already applied for this job!"; } } return(Page()); }