public async Task <ActionResult <itemDetail> > PostitemDetail(itemDetail itemDetail)
        {
            _context.itemDetailTable.Add(itemDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetitemDetail", new { id = itemDetail.itemId }, itemDetail));
        }
        public RedirectToRouteResult SaveItem(string itemId, string length, string width, string height, string weight, HttpPostedFileBase imgItem)
        {
            string thePictureDataAsString = "";

            if (imgItem != null)
            {
                string theFileName       = Path.GetFileName(imgItem.FileName);
                byte[] thePictureAsBytes = new byte[imgItem.ContentLength];
                using (BinaryReader theReader = new BinaryReader(imgItem.InputStream))
                {
                    thePictureAsBytes = theReader.ReadBytes(imgItem.ContentLength);
                }
                thePictureDataAsString = Convert.ToBase64String(thePictureAsBytes);
            }

            Item       item  = db.Items.Find(Convert.ToInt32(itemId));
            itemDetail itemd = db.itemDetails.Find(item.itemDetails);

            if (imgItem == null)
            {
            }
            else
            {
                itemd.picture = thePictureDataAsString;
            }
            itemd.weight     = weight;
            itemd.dimensions = length + "X" + width + "X" + height;

            db.SaveChanges();


            return(RedirectToAction("index"));
        }
        public async Task <IActionResult> PutitemDetail(int id, itemDetail itemDetail)
        {
            if (id != itemDetail.itemId)
            {
                return(BadRequest());
            }

            _context.Entry(itemDetail).State = EntityState.Modified;

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

            return(NoContent());
        }
        public IHttpActionResult PutitemDetail(int id, itemDetail itemDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetitemDetail(int id)
        {
            itemDetail itemDetail = db.itemDetails.Find(id);

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

            return(Ok(itemDetail));
        }
        public IHttpActionResult PostitemDetail(itemDetail itemDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.itemDetails.Add(itemDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = itemDetail.id }, itemDetail));
        }
        public IHttpActionResult DeleteitemDetail(int id)
        {
            itemDetail itemDetail = db.itemDetails.Find(id);

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

            db.itemDetails.Remove(itemDetail);
            db.SaveChanges();

            return(Ok(itemDetail));
        }