public int DeleteCategory(int categoryid)
        {
            tbl_category tc = _db.tbl_category.Where(c => c.Id == categoryid).FirstOrDefault();

            _db.tbl_category.Remove(tc);
            return(_db.SaveChanges());
        }
        public ActionResult Edit(int id, tbl_category category, HttpPostedFileBase image, string name)
        {
            var singleCategory = db.tbl_category.Where(x => x.CategoryId == id).SingleOrDefault();

            if (image != null)
            {
                if (System.IO.File.Exists(Server.MapPath(singleCategory.tbl_photo.URL)))
                {
                    System.IO.File.Delete(Server.MapPath(singleCategory.tbl_photo.URL));
                }
                string pictureName      = Guid.NewGuid().ToString().Replace("-", "");
                string pictureExtension = Path.GetExtension(Request.Files[0].FileName);
                string pictureWay       = "/Upload/images/" + pictureName + pictureExtension;
                Request.Files[0].SaveAs(Server.MapPath(pictureWay));
                singleCategory.tbl_photo.URL = pictureWay;
                singleCategory.Name          = name;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                singleCategory.Name = name;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
Example #3
0
 public bool InsertCategory(mCategory pCat)
 {
     try
     {
         tbl_category vCat  = new tbl_category();
         var          query = from b in Db.tbl_category
                              orderby b.category_id descending
                              select b;
         vCat = query.FirstOrDefault();
         tbl_category c = new tbl_category();
         c.category_title    = pCat.category_title;
         c.category_href     = pCat.category_href;
         c.category_parent   = pCat.category_parent;
         c.category_title_en = pCat.category_title_en;
         c.category_href_en  = pCat.category_href_en;
         c.category_img      = pCat.category_img;
         c.category_show_loc = pCat.category_show_loc;
         c.category_parent   = pCat.category_parent;
         c.category_type     = pCat.category_type;
         c.category_id       = vCat.category_id + 1;
         Db.tbl_category.Add(c);
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public CategoryModel UpdateCategory(CategoryModel _objdata)
        {
            tbl_category _objcategory = new tbl_category();

            try
            {
                using (newconecommerce dataContext = new newconecommerce())
                {
                    dataContext.Database.Connection.Open();
                    var _query = dataContext.tbl_category.Where(x => x.int_id == _objdata.intCategoryId).FirstOrDefault();
                    if (_query != null)
                    {
                        tbl_category _log = new tbl_category();

                        _log            = dataContext.tbl_category.Where(x => x.int_id == _objdata.intCategoryId).FirstOrDefault();
                        _log.v_category = _objdata.strCategoryName;

                        dataContext.SaveChanges();
                        dataContext.Database.Connection.Close();
                    }
                    _objdata.StatusMessaage = "Category updated sucessfully.";
                    return(_objdata);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #5
0
        public ActionResult Viewcontest(int?id)
        {
            Addmodel       ad = new Addmodel();
            tbl_tournament t  = db.tbl_tournament.Where(x => x.t_id == id).SingleOrDefault();

            ad.t_id       = t.t_id;
            ad.t_name     = t.t_name;
            ad.t_image    = t.t_image;
            ad.t_website  = t.t_website;
            ad.t_add      = t.t_add;
            ad.t_contact  = t.t_contact;
            ad.t_dts      = t.t_dts;
            ad.t_dte      = t.t_dte;
            ad.t_cat      = t.t_cat;
            ad.t_fk       = t.t_fk;
            ad.t_prize    = t.t_prize;
            ad.t_desc     = t.t_desc;
            ad.t_location = t.t_location;
            ad.t_entryfee = t.t_entryfee;
            tbl_category cat = db.tbl_category.Where(x => x.c_id == t.t_cat).SingleOrDefault();

            ad.c_name = cat.c_name;
            tbl_user user = db.tbl_user.Where(x => x.u_id == t.t_fk).SingleOrDefault();

            ad.u_name  = user.u_name;
            ad.u_img   = user.u_img;
            ad.u_desc  = user.u_desc;
            ad.u_email = user.u_email;
            ad.t_fk    = user.u_id;
            //var list = ad.ToList();
            return(View(ad));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "CategoryId,Ad,PhotoId,Aciqlama,Keyword")] tbl_category tbl_category, HttpPostedFileBase Sekil)
        {
            if (ModelState.IsValid)
            {
                if (Sekil != null)
                {
                    if (Sekil.ContentLength > 0)
                    {
                        Image  img        = Image.FromStream(Sekil.InputStream);
                        Bitmap kiciksekil = new Bitmap(img, Settings.SekilKicikBoy);
                        kiciksekil.Save(Server.MapPath("/Upload/Sekiller/balaca" + Sekil.FileName));
                        tbl_sekil skl = new tbl_sekil();
                        skl.Kicik = "/Upload/Sekiller/balaca" + Sekil.FileName;
                        db.tbl_sekil.Add(skl);
                        db.SaveChanges();
                        tbl_category.PhotoId = skl.PhotoId;
                        db.tbl_category.Add(tbl_category);
                        db.SaveChanges();
                    }
                }


                return(RedirectToAction("Index"));
            }

            //ViewBag.PhotoId = new SelectList(db.tbl_sekil, "PhotoId", "Kicik", tbl_category.PhotoId);
            return(View(tbl_category));
        }
        public int UpdateCategory(CategoryDetails cd)
        {
            tbl_category tc = _db.tbl_category.Where(c => c.Id == cd.Id).FirstOrDefault();

            tc.CategoryName = cd.CategoryName;
            tc.AddedDate    = cd.AddedDate;
            return(_db.SaveChanges());
        }
        public ActionResult Delete(Int32 id)
        {
            tbl_category tb = db.tbl_categories.Where(x => x.cat_id == id).Single <tbl_category>();

            db.tbl_categories.DeleteOnSubmit(tb);
            db.SubmitChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Deletedconfirmed(int id)
        {
            tbl_category tbl_cat = db.tbl_category.Find(id);

            db.tbl_category.Remove(tbl_cat);
            db.SaveChanges();
            return(RedirectToAction("ViewCategory"));
        }
Example #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_category tbl_category = db.tbl_category.Find(id);

            db.tbl_category.Remove(tbl_category);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #11
0
 public ActionResult Edit(tbl_category category)
 {
     if (category != null)
     {
         repository.Update(category);
     }
     return(RedirectToAction("/"));
 }
        public ActionResult addcat(category ct)
        {
            tbl_category tr = new tbl_category();

            tr.cname = ct.cname;
            dc.tbl_category.Add(tr);
            dc.SaveChanges();
            return(View());
        }
 public ActionResult CategoryUpdate(int id, tbl_category tbl_Category)
 {
     using (BlogEntities db = new BlogEntities())
     {
         db.Entry(tbl_Category).State = EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToAction("Category"));
 }
 public ActionResult CategoryCreate(tbl_category tbl_Category)
 {
     using (BlogEntities db = new BlogEntities())
     {
         db.tbl_category.Add(tbl_Category);
         db.SaveChanges();
     }
     return(RedirectToAction("Category"));
 }
        public ActionResult Edit(tbl_category std)
        {
            db.Entry(std).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));


            return(View());
        }
        public int AddNewCategory(CategoryDetails cd)
        {
            tbl_category tc = new tbl_category();

            tc.CategoryName = cd.CategoryName;
            tc.AddedDate    = cd.AddedDate;
            _db.tbl_category.Add(tc);
            return(_db.SaveChanges());
        }
Example #17
0
        public ActionResult DeleteCategory(int?id)
        {
            tbl_category p = db.tbl_category.Where(x => x.cat_id == id).SingleOrDefault();

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

            return(RedirectToAction("ViewCategory"));
        }
        public ActionResult Create(Model_category obj)
        {
            tbl_category tb = new tbl_category();

            tb.cat_name = obj.cat_name;
            tb.cat_des  = obj.cat_des;
            db.tbl_categories.InsertOnSubmit(tb);
            db.SubmitChanges();
            return(RedirectToAction("Index"));
        }
Example #19
0
 public ActionResult Edit([Bind(Include = "Id,anbarId,subject,active")] tbl_category tbl_category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_category));
 }
        public ActionResult Edit(Model_category obj)
        {
            tbl_category tb = db.tbl_categories.Where(x => x.cat_id == obj.cat_id).Single <tbl_category>();

            tb.cat_id   = obj.cat_id;
            tb.cat_name = obj.cat_name;
            tb.cat_des  = obj.cat_des;
            db.SubmitChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Delete(int?id)
 {
     if (id != null)
     {
         tbl_category cs = db.tbl_category.Find(id);
         db.tbl_category.Remove(cs);
         db.SaveChanges();
         return(RedirectToAction("Index", "Home"));
     }
     return(View());
 }
Example #22
0
 public ActionResult Edit([Bind(Include = "CategoryId,Ad,PhotoId,Aciqlama,Keyword")] tbl_category tbl_category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PhotoId = new SelectList(db.tbl_sekil, "PhotoId", "Kicik", tbl_category.PhotoId);
     return(View(tbl_category));
 }
Example #23
0
        public ActionResult Create([Bind(Include = "Id,anbarId,subject,active")] tbl_category tbl_category)
        {
            if (ModelState.IsValid)
            {
                db.tbl_category.Add(tbl_category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_category));
        }
 public ActionResult CategoryDelete(int id, tbl_category tbl_Category)
 {
     using (BlogEntities db = new BlogEntities())
     {
         db.Entry(tbl_Category).State = EntityState.Deleted;
         var article = db.tbl_article.Where(x => x.CategoryID == id);
         db.tbl_article.RemoveRange(article);
         db.SaveChanges();
     }
     return(RedirectToAction("Category"));
 }
        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 category(categoryviewmodel obj)
        {
            tbl_category t = new tbl_category();

            t.cat_name = obj.cat_name;
            db.tbl_category.Add(t);
            db.SaveChanges();
            return(RedirectToAction("Index"));



            return(View());
        }
 public ActionResult Edit([Bind(Include = "categoryid,categoryname,categorydescription,entryby,entrydate,isactive")] tbl_category tbl_category)
 {
     if (ModelState.IsValid)
     {
         tbl_category.entryby         = "shafi";
         tbl_category.entrydate       = DateTime.Now;
         tbl_category.isactive        = 1;
         db.Entry(tbl_category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_category));
 }
Example #28
0
        // GET: AdminPanel/Kateqoriya/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_category tbl_category = db.tbl_category.Find(id);

            if (tbl_category == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_category));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            tbl_category tbl_category = db.tbl_category.Find(id);

            if (tbl_category == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_category));
        }
Example #30
0
        // GET: AdminPanel/Kateqoriya/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_category tbl_category = db.tbl_category.Find(id);

            if (tbl_category == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PhotoId = new SelectList(db.tbl_sekil, "PhotoId", "Kicik", tbl_category.PhotoId);
            return(View(tbl_category));
        }