Exemple #1
0
        public ActionResult Delete(int?id)
        {
            tabelcategory p = db.tabelcategories.Where(x => x.cat_id == id).SingleOrDefault();

            db.tabelcategories.Remove(p);
            db.SaveChanges();

            return(RedirectToAction("ViewCategory"));
        }
Exemple #2
0
        public ActionResult Create(tabelcategory cvm, HttpPostedFileBase imgfile)
        {
            string path = uploadimgfile(imgfile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                tabelcategory cat = new tabelcategory();
                cat.cat_name   = cvm.cat_name;
                cat.cat_image  = path;
                cat.cat_status = 1;
                cat.cat_fk_ad  = Convert.ToInt32(Session["ad_id"].ToString());
                db.tabelcategories.Add(cat);
                db.SaveChanges();
                return(RedirectToAction("ViewCategory"));
            }

            return(View());
        }
        public ActionResult ViewAd(int?id)
        {
            Adviewmodel  ad = new Adviewmodel();
            tabelproduct p  = db.tabelproducts.Where(x => x.pro_id == id).SingleOrDefault();

            ad.pro_id    = p.pro_id;
            ad.pro_name  = p.pro_name;
            ad.pro_image = p.pro_image;
            ad.pro_price = p.pro_price;
            ad.pro_des   = p.pro_des;
            tabelcategory cat = db.tabelcategories.Where(x => x.cat_id == p.pro_fk_cat).SingleOrDefault();

            ad.cat_name = cat.cat_name;
            tabeluser u = db.tabelusers.Where(x => x.u_id == p.pro_fk_user).SingleOrDefault();

            ad.u_name      = u.u_name;
            ad.u_image     = u.u_image;
            ad.u_contact   = u.u_contact;
            ad.pro_fk_user = u.u_id;



            return(View(ad));
        }