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 ActionResult Edit(Application application) { if (ModelState.IsValid) { db.Update(application); TempData["Message"] = "You have saved the application!"; return(RedirectToAction("Details", new { id = application.Id })); } return(View(application)); }
public IActionResult Accept(int id, string accept = "true") { var application = _applicationData.GetAll().FirstOrDefault(a => a.ApplicationId == id); if (application == null) { return(RedirectToAction("Index")); } if (accept != "true") { application.State = "Deny"; } else { application.State = "Accept"; } _applicationData.Update(application); _applicationData.Commit(); return(RedirectToAction("Index")); }