public IHttpActionResult PutFeatured(int id, FeaturedDTO modified)
        {
            if (!FeaturedExists(id))
            {
                return(NotFound());
            }

            Featured thisFeature = (from x in db.Featureds
                                    where x.Id == id
                                    select x).First();

            thisFeature.Id        = modified.Id;
            thisFeature.ProductId = modified.ProductId;

            //db.Entry(featured).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private FeaturedDTO ToDTO(Featured f)
 {
     return(new FeaturedDTO()
     {
         Id = f.Id,
         ProductId = f.ProductId
     });
 }
        public IHttpActionResult PostFeatured(FeaturedDTO featuredInfo)
        {
            Featured NewFeatured = ToEntity(featuredInfo);

            db.Featureds.Add(NewFeatured);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = NewFeatured.Id }, NewFeatured));
        }
        public IHttpActionResult GetFeatured(int id)
        {
            Featured featured = db.Featureds.Find(id);

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

            return(Ok(ToDTO(featured)));
        }
        public IHttpActionResult DeleteFeatured(int id)
        {
            Featured featured = db.Featureds.Find(id);

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

            db.Featureds.Remove(featured);
            db.SaveChanges();

            return(Ok(featured));
        }