private bool SendApplicationToDatabase(ApplyViewModel applyViewModel) { if (applyViewModel.ApplicationId > 0) { var application = _applicationData.FindById(applyViewModel.ApplicationId); if (application == null) { return(false); } application.Name = applyViewModel.Name; application.Phone = applyViewModel.Phone; application.CommunicationEmail = applyViewModel.CommunicationEmail; application.Info = applyViewModel.Info; application.CvFile = applyViewModel.CvFile; _applicationData.Update(application); } else { var jobOffer = _jobOfferData.FindById(applyViewModel.JobOfferId); if (jobOffer == null) { return(false); } var application = new Application(); application.UserEmail = User.FindFirst("emails").Value; application.ApplicationId = 0; application.JobOfferId = applyViewModel.JobOfferId; application.OfferName = jobOffer.Name; application.Name = applyViewModel.Name; application.Phone = applyViewModel.Phone; application.CommunicationEmail = applyViewModel.CommunicationEmail; application.Info = applyViewModel.Info; application.CvFile = applyViewModel.CvFile; _applicationData.Add(application); var hrEmail = _jobOfferData.GetHrEmail(applyViewModel.JobOfferId); if (hrEmail != null) { var apikey = _configuration["sendgridapikey"]; SendGridService.SendEmail(hrEmail, applyViewModel.OfferName, apikey, application.CvFile); } } _applicationData.Commit(); return(true); }
public IActionResult Evaluate(int id) { var application = _applicationData.FindById(id); if (application == null) { return(RedirectToAction("Index")); } return(View(application)); }