Ejemplo n.º 1
0
        public async Task <ActionResult> Index(int?id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }


            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(RedirectToAction("Index", "Inventory"));
            }



            inv_Inventory inv_Inventory2 = await db.inv_Inventory.FindAsync(id);

            if (inv_Inventory2 == null)
            {
                //return HttpNotFound();
                return(RedirectToAction("Index", "Inventory"));
            }
            //return View(inv_Inventory);


            Session["ii"] = id;
            //ViewBag.EmployeeData =   inv_Inventory.ToList();
            return(View(inv_Inventory2));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Save(inv_Inventory Inventory)
        {
            int status = 0;

            if (ModelState.IsValid)
            {
                if (Inventory.InvertoryID > 0)
                {
                    //Edit
                    var v = db.inv_Inventory.Where(a => a.InvertoryID == Inventory.InvertoryID).FirstOrDefault();
                    if (v != null)
                    {
                        v.InvertoryNameAr    = Inventory.InvertoryNameAr;
                        v.InvertoryAddressAr = Inventory.InvertoryAddressAr;
                        v.InvertoryRent      = Inventory.InvertoryRent;
                        v.InvertoryRentDate  = Inventory.InvertoryRentDate;

                        status = 1;
                    }
                }
                else
                {
                    //Save
                    db.inv_Inventory.Add(Inventory);
                    status = 2;
                }
                await db.SaveChangesAsync();
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            inv_Inventory inv_Inventory = await db.inv_Inventory.FindAsync(id);

            db.inv_Inventory.Remove(inv_Inventory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Edit([Bind(Include = "InvertoryID,InvertoryNameAr,InvertoryNameEn,InvertoryAddressAr,InvertoryAddressEn,InvertoryAddDate,InvertoryRent,InvertoryRentDate")] inv_Inventory inv_Inventory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(inv_Inventory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(inv_Inventory));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Create([Bind(Include = "InvertoryID,InvertoryNameAr,InvertoryNameEn,InvertoryAddressAr,InvertoryAddressEn,InvertoryAddDate,InvertoryRent,InvertoryRentDate")] inv_Inventory inv_Inventory)
        {
            if (ModelState.IsValid)
            {
                db.inv_Inventory.Add(inv_Inventory);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(inv_Inventory));
        }
Ejemplo n.º 6
0
        // GET: Inventory/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            inv_Inventory inv_Inventory = await db.inv_Inventory.FindAsync(id);

            if (inv_Inventory == null)
            {
                return(HttpNotFound());
            }
            return(View(inv_Inventory));
        }