Beispiel #1
0
        public async Task <IHttpActionResult> PutAttributeProduct(int id, AttributeProduct attributeProduct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AttributeProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetAttributeProduct(int id)
        {
            AttributeProduct attributeProduct = await db.AttributeProduct.FindAsync(id);

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

            return(Ok(attributeProduct));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> PostAttributeProduct(AttributeProduct attributeProduct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AttributeProduct.Add(attributeProduct);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = attributeProduct.Id }, attributeProduct));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> DeleteAttributeProduct(int id)
        {
            AttributeProduct attributeProduct = await db.AttributeProduct.FindAsync(id);

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

            db.AttributeProduct.Remove(attributeProduct);
            await db.SaveChangesAsync();

            return(Ok(attributeProduct));
        }