public ActionResult addproduct(pclass f, HttpPostedFileBase file1)
        {
            ViewBag.cat = new SelectList(dc.tbl_category, "catid", "catname");
            tbl_product pr = new tbl_product();

            pr.pname     = f.pname;
            pr.pcategory = f.catid;
            pr.pprice    = f.pprice;
            pr.pdetail   = f.pdetail;
            if (file1 != null)
            {
                filename = file1.FileName;
                path     = Server.MapPath("~/img/");
                fulpath  = path + filename;
                file1.SaveAs(fulpath);
                temp = "~/img/" + filename;
            }
            else
            {
                temp = "";
            }
            pr.pimage = temp;
            dc.tbl_product.Add(pr);
            dc.SaveChanges();
            return(View());
        }
        public ActionResult Edit(int id, pclass f)
        {
            var p = (from n in dc.tbl_category where n.catid == id select n).FirstOrDefault();

            //p.catid = f.catid;
            p.catname = f.catname;

            dc.SaveChanges();
            return(RedirectToAction("displaycat"));
        }
        public ActionResult Delete(int id)
        {
            var p = (from n in dc.tbl_category where n.catid == id select n).FirstOrDefault();

            pclass f = new pclass();

            f.catid   = p.catid;
            f.catname = p.catname;

            return(View(f));
        }
        public ActionResult addcat(pclass f)
        {
            tbl_category tr = new tbl_category();

            tr.catid   = f.catid;
            tr.catname = f.catname;

            dc.tbl_category.Add(tr);
            dc.SaveChanges();
            ViewBag.msg = "Insert Succesfully..";
            return(View());
        }
        public ActionResult displaycat()
        {
            var p     = from n in dc.tbl_category select n;
            var model = new List <pclass>();

            foreach (var item in p)
            {
                pclass f = new pclass();
                f.catid   = item.catid;
                f.catname = item.catname;

                model.Add(f);
            }
            return(View(model));
        }
        public ActionResult viewproduct()
        {
            ViewBag.cat = new SelectList(dc.tbl_category, "catid", "catname");

            var p     = from n in dc.tbl_product join m in dc.tbl_category on n.pcategory equals m.catid select new { n.pname, n.pdetail, n.pprice, n.pimage, m.catname };
            var model = new List <pclass>();

            foreach (var item in p)
            {
                pclass f = new pclass();
                f.pname   = item.pname;
                f.catname = item.catname;
                f.pprice  = int.Parse(item.pprice.ToString());
                f.pdetail = item.pdetail;
                f.pimage  = item.pimage;

                model.Add(f);
            }
            return(View(model));
        }