public ActionResult DeleteConfirmed(int id)
        {
            agent_storage agent_storage = db.agent_storage.Find(id);

            db.agent_storage.Remove(agent_storage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,id_agent,id_book,quantity")] agent_storage agent_storage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(agent_storage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_agent = new SelectList(db.agents, "id", "name", agent_storage.id_agent);
     ViewBag.id_book  = new SelectList(db.books, "id", "name", agent_storage.id_book);
     return(View(agent_storage));
 }
        // GET: agent_storage/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            agent_storage agent_storage = db.agent_storage.Find(id);

            if (agent_storage == null)
            {
                return(HttpNotFound());
            }
            return(View(agent_storage));
        }
        // GET: agent_storage/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            agent_storage agent_storage = db.agent_storage.Find(id);

            if (agent_storage == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_agent = new SelectList(db.agents, "id", "name", agent_storage.id_agent);
            ViewBag.id_book  = new SelectList(db.books, "id", "name", agent_storage.id_book);
            return(View(agent_storage));
        }
        public ActionResult addStore(int agent_id, int id_book, int quantity)
        {
            //Check Exists
            int check = checkBook(agent_id, id_book);

            if (check > 0)
            {
                updateStore(agent_id, id_book, quantity);
                return(Json(new { con = "update" }));
            }
            agent_storage stg = new agent_storage();

            stg.id_agent = agent_id;
            stg.id_book  = id_book;
            stg.quantity = quantity;
            db.agent_storage.Add(stg);
            db.SaveChanges();
            return(Json(new { con = "add" }));
        }