Beispiel #1
0
        public IHttpActionResult PutDriver(int id, MicWay.Driver.Library.Models.Driver driver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != driver.Id)
            {
                return(BadRequest());
            }

            db.Entry(driver).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DriverExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetDriver(int id)
        {
            MicWay.Driver.Library.Models.Driver driver = db.Driver.Find(id);
            if (driver == null)
            {
                return(NotFound());
            }

            return(Ok(driver));
        }
Beispiel #3
0
        public IHttpActionResult PostDriver(MicWay.Driver.Library.Models.Driver driver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Driver.Add(driver);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = driver.Id }, driver));
        }
Beispiel #4
0
        public IHttpActionResult DeleteDriver(int id)
        {
            MicWay.Driver.Library.Models.Driver driver = db.Driver.Find(id);
            if (driver == null)
            {
                return(NotFound());
            }

            db.Driver.Remove(driver);
            db.SaveChanges();

            return(Ok(driver));
        }