コード例 #1
0
ファイル: daGallery.cs プロジェクト: bargebaloot/Alstar
 public mGallery fGetGallery(mGallery pGallery)
 {
     try
     {
         var vGallery = (from g in Db.tbl_gallery
                         where g.gallery_id.Equals(pGallery.gallery_id)
                         select new mGallery
         {
             gallery_id = g.gallery_id,
             gallery_image = g.gallery_image,
             gallery_date = g.gallery_date,
             gallery_title = g.gallery_title,
             gallery_title_en = g.gallery_title_en,
             gallery_alt = g.gallery_alt,
             gallery_cat = g.gallery_cat,
             gallery_exp_en = g.gallery_exp_en,
             gallery_exp = g.gallery_exp,
             gallery_is_fa = g.gallery_is_fa,
             gallery_summery_en = g.gallery_summery_en,
             gallery_summery = g.gallery_summery,
             gallery_visit = g.gallery_visit
         }).FirstOrDefault();
         return(vGallery);
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #2
0
ファイル: daGallery.cs プロジェクト: bargebaloot/Alstar
 public bool InsertGallery(mGallery pGallery)
 {
     try
     {
         tbl_gallery vGallery = new tbl_gallery();
         var         query    = from b in Db.tbl_gallery
                                orderby b.gallery_id descending
                                select b;
         vGallery = query.FirstOrDefault();
         tbl_gallery g = new tbl_gallery();
         g.gallery_title      = pGallery.gallery_title;
         g.gallery_title_en   = pGallery.gallery_title_en;
         g.gallery_image      = pGallery.gallery_image;
         g.gallery_alt        = pGallery.gallery_alt;
         g.gallery_date       = pGallery.gallery_date;
         g.gallery_summery    = pGallery.gallery_summery;
         g.gallery_summery_en = pGallery.gallery_summery_en;
         g.gallery_exp        = pGallery.gallery_exp;
         g.gallery_exp_en     = pGallery.gallery_exp_en;
         g.gallery_is_fa      = pGallery.gallery_is_fa;
         g.gallery_cat        = pGallery.gallery_cat;
         g.gallery_id         = vGallery.gallery_id + 1;
         Db.tbl_gallery.Add(g);
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #3
0
ファイル: daGallery.cs プロジェクト: bargebaloot/Alstar
 public bool fUpdateGallery(mGallery pGallery)
 {
     try
     {
         tbl_gallery g = new tbl_gallery();
         g.gallery_id         = pGallery.gallery_id;
         g.gallery_image      = pGallery.gallery_image;
         g.gallery_date       = pGallery.gallery_date;
         g.gallery_title      = pGallery.gallery_title;
         g.gallery_title_en   = pGallery.gallery_title_en;
         g.gallery_alt        = pGallery.gallery_alt;
         g.gallery_summery    = pGallery.gallery_summery;
         g.gallery_summery_en = pGallery.gallery_summery_en;
         g.gallery_exp        = pGallery.gallery_exp;
         g.gallery_is_fa      = pGallery.gallery_is_fa;
         g.gallery_exp_en     = pGallery.gallery_exp_en;
         g.gallery_cat        = pGallery.gallery_cat;
         Db.tbl_gallery.Attach(g);
         Db.Entry(g).State = System.Data.Entity.EntityState.Modified;
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #4
0
 public ActionResult GalleryPost(mGallery pGallery)
 {
     if (fUserControl() == 0)
     {
         ViewBag.Message = "شما وارد سایت نشده اید...";
         return(RedirectToAction("LoginForm", "Login"));
     }
     if (!(ModelState.IsValid))
     {
         ViewBag.error = "خطا در  اطلاعات ورودی !";
         return(View(pGallery));
     }
     else
     {
         if (pGallery.img_file != null && pGallery.img_file.ContentLength > 0)
         {
             if (pGallery.img_file.ContentLength < 10485760)
             {
                 Random rnd  = new Random();
                 string img  = rnd.Next().ToString() + ".jpg";
                 string Path = System.IO.Path.Combine(Server.MapPath("~/images/gallery/"));
                 pGallery.img_file.SaveAs(Path + img);
                 using (MemoryStream ms = new MemoryStream())
                 {
                     pGallery.img_file.InputStream.CopyTo(ms);
                     byte[] array = ms.GetBuffer();
                     pGallery.gallery_image = img;
                 }
             }
             else
             {
                 ViewBag.error = "حد اکثر اندازه فایل را رعایت نکرده اید !";
                 return(View(pGallery));
             }
         }
         if (pGallery.gallery_id > 0)
         {
             if (g.fUpdateGallery(pGallery))
             {
                 return(RedirectToAction("index", new { pId = pGallery.gallery_cat }));
             }
             ViewBag.error = "خطا در انجام عملیات  ! ";
         }
         else
         {
             if (g.InsertGallery(pGallery))
             {
                 return(RedirectToAction("index", new { pId = pGallery.gallery_cat }));
             }
             ViewBag.error = "خطا در انجام عملیات  ! ";
         }
     }
     return(View(pGallery));
 }
コード例 #5
0
        public ActionResult GalleryGet(int pId = 0, int pType = 0)
        {
            if (fUserControl() == 0)
            {
                ViewBag.Message = "شما وارد سایت نشده اید...";
                return(RedirectToAction("LoginForm", "Login"));
            }
            mGallery vGallery = new mGallery();

            if (pId > 0)
            {
                vGallery.gallery_id = pId;
                vGallery            = g.fGetGallery(vGallery);
            }
            else
            {
                vGallery = new mGallery();
            }
            vGallery.gallery_cat = pType;
            return(View("_Gallery", vGallery));
        }