public IHttpActionResult PutStationsOnLine(int id, StationsOnLine stationsOnLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stationsOnLine.StationsOnLineID) { return(BadRequest()); } try { unitOfWork.StationsOnLine.Update(stationsOnLine); unitOfWork.Complete(); } catch (DbUpdateConcurrencyException) { if (!StationsOnLineExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetStationsOnLine(int id) { StationsOnLine stationsOnLine = unitOfWork.StationsOnLine.Get(id); if (stationsOnLine == null) { return(NotFound()); } return(Ok(stationsOnLine)); }
public IHttpActionResult PostStationsOnLine(StationsOnLine stationsOnLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { unitOfWork.StationsOnLine.Add(stationsOnLine); unitOfWork.Complete(); } catch { throw; } return(CreatedAtRoute("DefaultApi", new { id = stationsOnLine.StationsOnLineID }, stationsOnLine)); }
public IHttpActionResult DeleteStationsOnLine(int id) { StationsOnLine stationsOnLine = unitOfWork.StationsOnLine.Get(id); if (stationsOnLine == null) { return(NotFound()); } try { unitOfWork.StationsOnLine.Remove(stationsOnLine); unitOfWork.Complete(); } catch { throw; } return(Ok(stationsOnLine)); }