コード例 #1
0
        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));
        }
コード例 #2
0
        public IHttpActionResult GetStationsOnLine(int id)
        {
            StationsOnLine stationsOnLine = unitOfWork.StationsOnLine.Get(id);

            if (stationsOnLine == null)
            {
                return(NotFound());
            }

            return(Ok(stationsOnLine));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }