public async Task <IActionResult> PostLineRollingGuide([FromBody] LineRollingGuide lineRollingGuide) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.LineRollingGuides.Add(lineRollingGuide); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (LineRollingGuideExists(lineRollingGuide.TypeID)) { return(StatusCode((int)HttpStatusCode.Conflict)); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = lineRollingGuide.TypeID }, lineRollingGuide)); }
public async Task <IActionResult> PutLineRollingGuide(string id, [FromBody] LineRollingGuide lineRollingGuide) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lineRollingGuide.TypeID) { return(BadRequest()); } db.Entry(lineRollingGuide).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LineRollingGuideExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode((int)HttpStatusCode.NoContent)); }
public async Task <IActionResult> GetLineRollingGuide(string id) { LineRollingGuide lineRollingGuide = await db.LineRollingGuides.FindAsync(id); if (lineRollingGuide == null) { return(NotFound()); } return(Ok(lineRollingGuide)); }
public async Task <IActionResult> DeleteLineRollingGuide(string id) { LineRollingGuide lineRollingGuide = await db.LineRollingGuides.FindAsync(id); if (lineRollingGuide == null) { return(NotFound()); } db.LineRollingGuides.Remove(lineRollingGuide); await db.SaveChangesAsync(); return(Ok(lineRollingGuide)); }