Esempio n. 1
0
        public IHttpActionResult PutShopVisit(int id, ShopVisit shopVisit)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult GetShopVisit(int id)
        {
            ShopVisit shopVisit = db.ShopVisits.Find(id);

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

            return(Ok(shopVisit));
        }
Esempio n. 3
0
        public IHttpActionResult PostShopVisit(ShopVisit shopVisit)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ShopVisits.Add(shopVisit);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = shopVisit.Id }, shopVisit));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteShopVisit(int id)
        {
            ShopVisit shopVisit = db.ShopVisits.Find(id);

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

            db.ShopVisits.Remove(shopVisit);
            db.SaveChanges();

            return(Ok(shopVisit));
        }