public ActionResult Edit(ApplicantEdit applicantEdit) { if (Request.IsAuthenticated) { try { ApplicantWeb.Models.Applicant applicant = db.Applicants.Find(applicantEdit.ApplicantId); if (ModelState.IsValid) { applicant.Edit(applicantEdit); db.Entry(applicant).State = EntityState.Modified; db.SaveChanges(); return(Redirect(Url.Action("Details", "Applicants", new { id = applicant.ApplicantId }))); } return(View(applicant)); } catch { return(HttpNotFound()); } } else { return(Redirect(Url.Action("Login", "Account"))); } }
// GET: Applicants/Create public async Task <IActionResult> Create(int?id) { if (id == null) { return(NotFound()); } //The user should have an author if not 0 or 1 ViewData["CareerID"] = id; //Model defined in Models/ViewModels/BlogEdit.cs ApplicantEdit blogeditview = new ApplicantEdit(); return(View(blogeditview)); }
// GET: Applicants/Create public async Task <IActionResult> Create(int?id) { if (id == null) { return(NotFound()); } //To Create an applicant for particular career ViewData["CareerID"] = id; //Model defined in Models/ViewModels/ApplicantEdit.cs ApplicantEdit applicanteditView = new ApplicantEdit(); return(View(applicanteditView)); }
public IHttpActionResult Put(ApplicantEdit application) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateApplicantServices(); if (!service.UpdateApplicant(application)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateApplicant(ApplicantEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Applicants.SingleOrDefault(e => e.ApplicantId == model.ApplicantId && e.OwnerId == _userId); if (entity is null) { return(false); } entity.ApplicantFirstName = model.ApplicantFirstName; entity.ApplicantLastName = model.ApplicantLastName; entity.ApplicantEmail = model.ApplicantEmail; return(ctx.SaveChanges() == 1); } }