Beispiel #1
0
        public IHttpActionResult PutBrandInfo(int id, Data.BrandInfo brandInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult PostBrandInfo(Data.BrandInfo brandInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BrandInfoes.Add(brandInfo);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = brandInfo.id }, brandInfo));
        }
Beispiel #3
0
        public IHttpActionResult GetBrandInfo(int id)
        {
            Data.BrandInfo brandInfo = db.BrandInfoes.Find(id);



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

            return(Ok(brandInfo));
        }
Beispiel #4
0
        public IHttpActionResult DeleteBrandInfo(int id)
        {
            Data.BrandInfo brandInfo = db.BrandInfoes.Find(id);
            if (brandInfo == null)
            {
                return(NotFound());
            }

            db.BrandInfoes.Remove(brandInfo);
            db.SaveChanges();

            return(Ok(brandInfo));
        }