예제 #1
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);
     }
 }
예제 #2
0
 public mCategory fGetCategory(mCategory pCat)
 {
     try
     {
         var vCat = (from c in Db.tbl_category
                     where c.category_id.Equals(pCat.category_id)
                     select new mCategory
         {
             category_id = c.category_id,
             category_href = c.category_href,
             category_parent = c.category_parent,
             category_title = c.category_title,
             category_title_en = c.category_title_en,
             category_href_en = c.category_href_en,
             category_show_loc = c.category_show_loc,
             category_type = c.category_type,
             category_img = c.category_img
         }).FirstOrDefault();
         return(vCat);
     }
     catch (Exception)
     {
         return(null);
     }
 }
예제 #3
0
 public ActionResult CategoryPost(mCategory pCat)
 {
     if (fUserControl() == 0)
     {
         ViewBag.Message = "شما وارد سایت نشده اید...";
         return(RedirectToAction("LoginForm", "Login"));
     }
     if (!(ModelState.IsValid))
     {
         ViewBag.error = "خطا در  اطلاعات ورودی !";
         return(View(pCat));
     }
     else
     {
         if (pCat.img_file != null && pCat.img_file.ContentLength > 0)
         {
             if (pCat.img_file.ContentLength < 10485760)
             {
                 Random rnd  = new Random();
                 string img  = rnd.Next().ToString() + ".jpg";
                 string Path = System.IO.Path.Combine(Server.MapPath("~/images/category/"));
                 pCat.img_file.SaveAs(Path + img);
                 using (MemoryStream ms = new MemoryStream())
                 {
                     pCat.img_file.InputStream.CopyTo(ms);
                     byte[] array = ms.GetBuffer();
                     pCat.category_img = img;
                 }
             }
             else
             {
                 ViewBag.error = "حد اکثر اندازه فایل را رعایت نکرده اید !";
                 return(View(pCat));
             }
         }
         if (pCat.category_id > 0)
         {
             if (c.fUpdateCategory(pCat))
             {
                 return(RedirectToAction("index", new { pId = pCat.category_type }));
             }
             ViewBag.error = "خطا در انجام عملیات  ! ";
         }
         else
         {
             if (c.InsertCategory(pCat))
             {
                 return(RedirectToAction("index", new { pId = pCat.category_type }));
             }
             ViewBag.error = "خطا در انجام عملیات  ! ";
         }
     }
     return(View(pCat));
 }
예제 #4
0
        public ActionResult Index()
        {
            mHome     vHome = new mHome();
            mCategory vCat  = new mCategory();

            vCat.category_type = 3;
            List <mCategory> aCat = new List <mCategory>();

            aCat  = c.fCategoryList(12, 0, vCat.category_type);
            vHome = h.fGetHomeContent();
            if (vHome == null)
            {
                vHome = new mHome();
            }
            vHome.aCategoryGallery = aCat;
            return(View(vHome));
        }
예제 #5
0
        public ActionResult Blog()
        {
            mHome    vHome    = new mHome();
            mArticle vArticle = new mArticle();

            vArticle.article_type = 2;
            List <mArticle> aArticle = new List <mArticle>();
            mCategory       vCat     = new mCategory();

            vCat.category_type = 1;
            List <mCategory> aCat = new List <mCategory>();

            if (pSkip == 0)
            {
                vHome.page_number = 1;
            }
            else
            {
                vHome.page_number = (pSkip / 12) + 1;
            }
            aArticle = ar.fArticlesList(pGet, pSkip, vArticle, vHome);
            aCat     = c.fCategoryList(12, 0, vCat.category_type);

            if (aArticle != null && aArticle.Count > 0)
            {
                vHome.aArticles = aArticle;
            }
            else
            {
                vHome.aArticles = new List <mArticle>();
            }
            if (aCat != null && aCat.Count > 0)
            {
                vHome.aCategory = aCat;
            }
            else
            {
                vHome.aCategory = new List <mCategory>();
            }
            return(View(vHome));
        }
예제 #6
0
        public ActionResult CategoryGet(int pId = 0, int pType = 0)
        {
            if (fUserControl() == 0)
            {
                ViewBag.Message = "شما وارد سایت نشده اید...";
                return(RedirectToAction("LoginForm", "Login"));
            }
            mCategory vCat = new mCategory();

            if (pId > 0)
            {
                vCat.category_id = pId;
                vCat             = c.fGetCategory(vCat);
            }
            else
            {
                vCat = new mCategory();
            }
            vCat.category_type = pType;
            return(View("_Category", vCat));
        }
예제 #7
0
        public ActionResult resume()
        {
            int             pId      = 1;
            mHome           vHome    = new mHome();
            List <mGallery> aGallery = new List <mGallery>();
            mCategory       vCat     = new mCategory();

            vCat.category_type = 2;
            List <mCategory> aCat = new List <mCategory>();

            if (pSkip == 0)
            {
                vHome.page_number = 1;
            }
            else
            {
                vHome.page_number = (pSkip / 12) + 1;
            }
            aGallery = g.fGalleryList(pGet, pSkip, pId);
            aCat     = c.fCategoryList(12, 0, vCat.category_type);

            if (aGallery != null && aGallery.Count > 0)
            {
                vHome.aGallery = aGallery;
            }
            else
            {
                vHome.aGallery = new List <mGallery>();
            }
            if (aCat != null && aCat.Count > 0)
            {
                vHome.aCategory = aCat;
            }
            else
            {
                vHome.aCategory = new List <mCategory>();
            }
            return(View(vHome));
        }
예제 #8
0
        public ActionResult Centers(int?pId)
        {
            mHome     vHome   = new mHome();
            mCategory vCat    = new mCategory();
            mCenter   pCenter = new mCenter();

            vCat.category_type = 2;
            pCenter.center_cat = pId;
            List <mCategory> aCat    = new List <mCategory>();
            List <mCenter>   aCenter = new List <mCenter>();

            if (pSkip == 0)
            {
                vHome.page_number = 1;
            }
            else
            {
                vHome.page_number = (pSkip / 12) + 1;
            }
            aCenter = ce.fCenterList(pGet, pSkip, pCenter, vHome);
            aCat    = c.fCategoryList(20, 0, vCat.category_type);
            if (aCenter != null && aCenter.Count > 0)
            {
                vHome.aCenter = aCenter;
            }
            else
            {
                vHome.aCenter = new List <mCenter>();
            }
            if (aCat != null && aCat.Count > 0)
            {
                vHome.aCategory = aCat;
            }
            else
            {
                vHome.aCategory = new List <mCategory>();
            }
            return(View(vHome));
        }
예제 #9
0
        public ActionResult Videos()
        {
            mHome         vHome  = new mHome();
            List <mVideo> aVideo = new List <mVideo>();
            mCategory     vCat   = new mCategory();

            vCat.category_type = 2;
            List <mCategory> aCat = new List <mCategory>();

            if (pSkip == 0)
            {
                vHome.page_number = 1;
            }
            else
            {
                vHome.page_number = (pSkip / 12) + 1;
            }
            aVideo = v.fVidoeList(pGet, pSkip);
            aCat   = c.fCategoryList(12, 0, vCat.category_type);

            if (aVideo != null && aVideo.Count > 0)
            {
                vHome.aVideo = aVideo;
            }
            else
            {
                vHome.aVideo = new List <mVideo>();
            }
            if (aCat != null && aCat.Count > 0)
            {
                vHome.aCategory = aCat;
            }
            else
            {
                vHome.aCategory = new List <mCategory>();
            }
            return(View(vHome));
        }
예제 #10
0
 public bool fUpdateCategory(mCategory pCat)
 {
     try
     {
         tbl_category c = new tbl_category();
         c.category_id       = pCat.category_id;
         c.category_title    = pCat.category_title;
         c.category_parent   = pCat.category_parent;
         c.category_href     = pCat.category_href;
         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;
         Db.tbl_category.Attach(c);
         Db.Entry(c).State = System.Data.Entity.EntityState.Modified;
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }