public IHttpActionResult UpdateApplication(int id, [FromBody] EmployeeApplicant EmployeeApplicant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != EmployeeApplicant.EmployeeApplicantId) { return(BadRequest()); } db.Entry(EmployeeApplicant).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeApplicantExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult AddApplication(EmployeeApplicant EmployeeApplicant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EmployeeApplicant.Add(EmployeeApplicant); db.SaveChanges(); return(Ok(EmployeeApplicant.EmployeeApplicantId)); //return CreatedAtRoute("DefaultApi", new { id = EmployeeApplicant.EmployeeApplicantId }, EmployeeApplicant); }
public IHttpActionResult DeleteApplication(int id) { EmployeeApplicant EmployeeApplicant = db.EmployeeApplicant.Find(id); if (EmployeeApplicant == null) { return(NotFound()); } db.EmployeeApplicant.Remove(EmployeeApplicant); db.SaveChanges(); return(Ok(EmployeeApplicant)); }
public ActionResult Edit(int id, EmployeeApplicant EmployeeApplicant) { string url = "EmployeeApplicantsData/UpdateApplication/" + id; HttpContent content = new StringContent(jss.Serialize(EmployeeApplicant)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PostAsync(url, content).Result; if (response.IsSuccessStatusCode) { return(RedirectToAction("Details", new { id = EmployeeApplicant.EmployeeApplicantId })); } else { return(RedirectToAction("Error")); } }
public IHttpActionResult FindApplication(int id) { EmployeeApplicant EmployeeApplicant = db.EmployeeApplicant.Find(id); if (EmployeeApplicant == null) { return(NotFound()); } //A data transfer object model used to show only most relevant information EmployeeApplicantDto TempEmployeeApplicant = new EmployeeApplicantDto { EmployeeApplicantId = EmployeeApplicant.EmployeeApplicantId, Reason = EmployeeApplicant.Reason, Id = EmployeeApplicant.Id, CourseId = EmployeeApplicant.CourseId }; return(Ok(TempEmployeeApplicant)); }
public ActionResult Create(EmployeeApplicant EmployeeApplicant) { GetApplicationCookie(); //Add a new application to the database string url = "EmployeeApplicantsData/AddApplication"; HttpContent content = new StringContent(jss.Serialize(EmployeeApplicant)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PostAsync(url, content).Result; if (response.IsSuccessStatusCode) { int EmployeeApplicantId = response.Content.ReadAsAsync <int>().Result; return(RedirectToAction("Details", new { id = EmployeeApplicantId })); } else { return(RedirectToAction("Error")); } }