public async Task <IHttpActionResult> PutComplaintsType(int id, ComplaintsType complaintsType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != complaintsType.ComplaintTypeId) { return(BadRequest()); } db.Entry(complaintsType).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComplaintsTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> DeleteConfirmed(int id) { ComplaintsType complaintsType = await db.ComplaintsTypes.FindAsync(id); db.ComplaintsTypes.Remove(complaintsType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> GetComplaintsType(int id) { ComplaintsType complaintsType = await db.ComplaintsTypes.FindAsync(id); if (complaintsType == null) { return(NotFound()); } return(Ok(complaintsType)); }
public async Task <ActionResult> Edit([Bind(Include = "ComplaintTypeId,Code,Description")] ComplaintsType complaintsType) { if (ModelState.IsValid) { db.Entry(complaintsType).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(complaintsType)); }
public async Task <IHttpActionResult> PostComplaintsType(ComplaintsType complaintsType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ComplaintsTypes.Add(complaintsType); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = complaintsType.ComplaintTypeId }, complaintsType)); }
public async Task <ActionResult> Create([Bind(Include = "ComplaintTypeId,Code,Description")] ComplaintsType complaintsType) { if (ModelState.IsValid) { db.ComplaintsTypes.Add(complaintsType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(complaintsType)); }
public async Task <IHttpActionResult> DeleteComplaintsType(int id) { ComplaintsType complaintsType = await db.ComplaintsTypes.FindAsync(id); if (complaintsType == null) { return(NotFound()); } db.ComplaintsTypes.Remove(complaintsType); await db.SaveChangesAsync(); return(Ok(complaintsType)); }
// GET: ComplaintsTypes/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ComplaintsType complaintsType = await db.ComplaintsTypes.FindAsync(id); if (complaintsType == null) { return(HttpNotFound()); } return(View(complaintsType)); }