public IHttpActionResult PutBOOKS(int id, BOOKS bOOKS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public ActionResult Edit([Bind(Include = "Id,CategoryId,CompanyId,Name,Description,Price,Amount")] Product product)
        {
            if (!Request.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();

                //Change the image
                HttpPostedFileBase file = Request.Files["pic"];
                if (file.ContentLength > 0)
                {
                    Image  image = Image.FromStream(file.InputStream);
                    Bitmap bmp   = new Bitmap(image);

                    ImageHandler.SaveImage(bmp, product.Id);
                }

                return(RedirectToAction("Show", "Products", new { id = product.Id }));
            }
            return(View(product));
        }
        public async Task <IActionResult> PutCategory([FromRoute] int id, [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "CATEGORYID,CATEGORYNAME")] CATEGORIES cATEGORIES)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cATEGORIES).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cATEGORIES));
 }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Company company)
 {
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Admin"));
     }
     return(View(company));
 }
Exemple #6
0
        public ActionResult Edit([Bind(Include = "Id,ParentId,Name")] Category category)
        {
            if (!Request.IsAuthenticated)
            {
                return(Redirect("/Account/Login"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(category).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Admin"));
            }
            return(View(category));
        }