public async Task <IActionResult> CreateJobApplication(JobApplicationCreateView model) { if (!ModelState.IsValid) { return(View(model)); } string email = User.FindFirst(x => x.Type.Equals(ClaimTypes.Email)).Value; int? id = _context.Users.Where(x => x.Email == email).First().Id; if (id == null) { return(BadRequest($"id shouldn't not be null")); } JobApplication ja = new JobApplication { JobOfferId = model.JobOfferId, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, EmailAddress = model.EmailAddress, ContactAgreement = model.ContactAgreement, UserId = (int)id }; _storage.AddToStorage(ja, model.FormFile); await _sendgrid.SendMailNotification(ja); await _context.JobApplications.AddAsync(ja); await _context.SaveChangesAsync(); return(RedirectToAction("IndexUser", "Home")); }