Beispiel #1
0
        //Get:laptop/Edite
        public ActionResult EditLaptop(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Labtob data = db.Labtobs.Find(id);

            if (data == null)
            {
                return(HttpNotFound());
            }
            Laptop PassedData = new Laptop();

            PassedData.ID      = data.ProductID;
            PassedData.model   = data.model;
            PassedData.Details = data.Details;
            PassedData.Brand   = data.Brand;
            PassedData.Price   = data.Price;
            PassedData.sale    = data.sale;
            PassedData.PicesNO = data.PicesNO;
            PassedData.img     = data.img;


            Admon.name      = Adminloggedin.name;
            Admon.password  = Adminloggedin.password;
            Admon.Type      = Adminloggedin.type;
            ViewBag.Message = Admon;

            return(View(PassedData));
        }
Beispiel #2
0
        public ActionResult AddLaptop(Laptop laptop)
        {
            if (ModelState.IsValid)
            {
                Labtob labtopData = new Labtob();
                labtopData.img = new byte[laptop.file.ContentLength];
                MemoryStream target = new MemoryStream();
                laptop.file.InputStream.CopyTo(target);
                labtopData.img     = target.ToArray();
                labtopData.model   = laptop.model;
                labtopData.Details = laptop.Details;
                labtopData.Brand   = laptop.Brand;
                labtopData.Price   = laptop.Price;
                labtopData.sale    = laptop.sale;
                labtopData.PicesNO = laptop.PicesNO;

                db.Labtobs.Add(labtopData);
                db.SaveChanges();

                return(RedirectToAction("DashBoard"));
            }

            Admon.name      = Adminloggedin.name;
            Admon.password  = Adminloggedin.password;
            Admon.Type      = Adminloggedin.type;
            ViewBag.Message = Admon;

            return(View(laptop));
        }
Beispiel #3
0
        public ActionResult DeleteLaptopConfirmed(int id)
        {
            //Force refreshing browser
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
            Response.Cache.SetNoStore();

            Labtob data = db.Labtobs.Find(id);

            db.Labtobs.Remove(data);
            db.SaveChanges();
            return(RedirectToAction("DashBoard"));
        }
Beispiel #4
0
        /// <summary>
        /// //delet laptop
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public ActionResult DeleteLaptop(int?id)
        {
            //Force refreshing browser
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
            Response.Cache.SetNoStore();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Labtob data = db.Labtobs.Find(id);

            if (data == null)
            {
                return(HttpNotFound());
            }
            Admon.name      = Adminloggedin.name;
            Admon.password  = Adminloggedin.password;
            Admon.Type      = Adminloggedin.type;
            ViewBag.Message = Admon;

            return(View(data));
        }