Exemple #1
0
 public JsonResult GetPhotoByID(int id)
 {
     if (_session.IsLogin)
     {
         if (id == -1)
         {
             string jsonData = "";
             jsonData  = "{\"master\":" + new JavaScriptSerializer().Serialize(new Photo());
             jsonData += ",\"detail\":[]}";
             return(Json(jsonData, JsonRequestBehavior.AllowGet));
         }
         else
         {
             string  jsonData = "";
             PhotoBO _cls     = new PhotoBO();
             var     data     = _cls.GetPhotoByID(id);
             jsonData  = "{\"master\":" + new JavaScriptSerializer().Serialize(data[0]);
             jsonData += ",\"detail\":" + new JavaScriptSerializer().Serialize(data[1]) + "}";;
             return(Json(jsonData, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         RedirectToAction("index", "admin");
     }
     return(Json("[]", JsonRequestBehavior.AllowGet));
 }
Exemple #2
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         var obj         = new GalleryBO().Get(this.ConnectionHandler, keys);
         var photos      = new PhotoBO().Where(this.ConnectionHandler, photo => photo.GalleryId == obj.Id);
         var photoFacade = new PhotoFacade(this.ConnectionHandler);
         foreach (var pic in photos)
         {
             if (!photoFacade.Delete(pic.Id))
             {
                 throw new Exception("خطایی در حذف عکس وجود دارد");
             }
         }
         if (!new GalleryBO().Delete(this.ConnectionHandler, keys))
         {
             throw new Exception("خطایی در حذف گالری وجود دارد");
         }
         this.ConnectionHandler.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Exemple #3
0
        public JsonResult SavePhoto(Photo photo, List <PhotoDetail> detail)
        {
            PhotoBO cls      = new PhotoBO();
            bool    IsResult = cls.Save(photo, detail);

            return(Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet));
        }
 public PartialViewResult Photo(int id)
 {
     var data = new List<PhotoDetail>();
     PhotoBO cls = new PhotoBO();
     data = cls.GetPhotoDetail(id);
     return PartialView(data);
 }
Exemple #5
0
 public JsonResult GetPhoto()
 {
     try
     {
         if (_session.IsLogin)
         {
             string  jsonData = "[]";
             PhotoBO _cls     = new PhotoBO();
             var     data     = _cls.GetAll();
             if (data != null)
             {
                 jsonData = new JavaScriptSerializer().Serialize(data);
             }
             return(Json(jsonData, JsonRequestBehavior.AllowGet));
         }
         else
         {
             RedirectToAction("index", "admin");
         }
         return(Json("[]", JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json("[]", JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Gallery()
 {
     IPhoto _cls = new PhotoBO();
         List<vw_Photo> model = new List<vw_Photo>();
         model = _cls.GetData(_session.LangID, true);
         ViewBag.DefaultID = 1;
         return View(model);
 }
        public PartialViewResult Photo(int id)
        {
            var     data = new List <PhotoDetail>();
            PhotoBO cls  = new PhotoBO();

            data = cls.GetPhotoDetail(id);
            return(PartialView(data));
        }
 public ActionResult Index()
 {
     List<Photo> data = new List<Photo>();
     PhotoBO _cls = new PhotoBO();
     data = _cls.GetAll();
     ViewBag.id = data[0].ID;
     ViewBag.Count = data.Count();
     _session.IsLogin = false;
     return View(data);
 }
        public ActionResult Index()
        {
            List <Photo> data = new List <Photo>();
            PhotoBO      _cls = new PhotoBO();

            data             = _cls.GetAll();
            ViewBag.id       = data[0].ID;
            ViewBag.Count    = data.Count();
            _session.IsLogin = false;
            return(View(data));
        }
 public JsonResult AddNewPhoto(Photo photo, PhotoLang photoLang, List<PhotoDetail> detail, List<PhotoDetailLang> detailLang)
 {
     if (_session.IsLogin && _session.IsStore && _session.IsAdmin)
         {
             IPhoto _cls = new PhotoBO();
             var IsResult = _cls.AddNewPhoto(photo, photoLang, detail, detailLang);
             return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet);
         }
         else
             RedirectToAction("index", "backend");
         return Json("[]", JsonRequestBehavior.AllowGet);
 }
Exemple #11
0
 public JsonResult DeletePhoto(int id)
 {
     if (_session.IsLogin)
     {
         PhotoBO _cls     = new PhotoBO();
         var     IsResult = _cls.Delete(id);
         return(Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         RedirectToAction("index", "admin");
     }
     return(Json(new { IsOk = false }, JsonRequestBehavior.AllowGet));
 }
Exemple #12
0
        public static PhotoBO PhotoDOtoBO(PhotoDO from)
        {
            PhotoBO to = new PhotoBO();

            to.PhotoID       = from.PhotoID;
            to.PhotoName     = from.PhotoName;
            to.Height        = from.Height;
            to.Width         = from.Width;
            to.ExtensionType = from.ExtensionType;
            to.Size          = from.Size;
            to.DateCreated   = from.DateCreated;
            to.Photo         = from.Photo;
            to.Byte          = from.Byte;
            to.AlbumID       = from.AlbumID;
            to.AlbumName     = from.AlbumName;

            return(to);
        }
Exemple #13
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                var obj = new PhotoBO().Get(this.ConnectionHandler, keys);
                if (!new PhotoBO().Delete(this.ConnectionHandler, keys))
                {
                    throw new Exception("خطایی در حذف عکس وجود دارد");
                }
                if (
                    !FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection)
                    .Delete(obj.PicFile))
                {
                    throw new Exception("خطایی در حذف عکس وجود دارد");
                }

                this.ConnectionHandler.CommitTransaction();
                this.FileManagerConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
 public JsonResult GetPhoto()
 {
     try
     {
         if (_session.IsLogin)
         {
             string jsonData = "[]";
             PhotoBO _cls = new PhotoBO();
             var data = _cls.GetAll();
             if (data != null)
                 jsonData = new JavaScriptSerializer().Serialize(data);
             return Json(jsonData, JsonRequestBehavior.AllowGet);
         }
         else
             RedirectToAction("index", "admin");
         return Json("[]", JsonRequestBehavior.AllowGet);
     }
     catch
     {
         return Json("[]", JsonRequestBehavior.AllowGet);
     }
 }
Exemple #15
0
 public ActionResult Video()
 {
     IPhoto _cls = new PhotoBO();
         List<vw_Photo> model = new List<vw_Photo>();
         model = _cls.GetData(_session.LangID, false);
         return View(model);
 }
 public JsonResult SavePhoto(Photo photo, List<PhotoDetail> detail)
 {
     PhotoBO cls = new PhotoBO();
     bool IsResult = cls.Save(photo, detail);
     return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet);
 }
 public JsonResult SaveVideo(Photo photo, PhotoLang photolang)
 {
     IPhoto cls = new PhotoBO();
         bool IsResult = cls.SaveVideo(photo, photolang);
         return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet);
 }
 public JsonResult GetPhotoByID(long id)
 {
     if (_session.IsLogin && _session.IsStore && _session.IsAdmin)
         {
             if (id == -1)
             {
                 string jsonData = "";
                 jsonData = "{\"master\":" + new JavaScriptSerializer().Serialize(new vw_Photo());
                 jsonData += ",\"detail\":[]}";
                 return Json(jsonData, JsonRequestBehavior.AllowGet);
             }
             else
             {
                 string jsonData = "";
                 IPhoto _cls = new PhotoBO();
                 var data = _cls.GetPhotoByID(_session.LangID, id);
                 jsonData = "{\"master\":" + new JavaScriptSerializer().Serialize(data[0]);
                 jsonData += ",\"detail\":" + new JavaScriptSerializer().Serialize(data[1]) + "}"; ;
                 return Json(jsonData, JsonRequestBehavior.AllowGet);
             }
         }
         else
             RedirectToAction("index", "admin");
         return Json("[]", JsonRequestBehavior.AllowGet);
 }
 public JsonResult GetVideo()
 {
     if (_session.IsLogin && _session.IsStore && _session.IsAdmin)
         {
             string jsonData = "[]";
             IPhoto _cls = new PhotoBO();
             var data = _cls.GetData(_session.LangID, false);
             if (data != null)
                 jsonData = new JavaScriptSerializer().Serialize(data);
             return Json(jsonData, JsonRequestBehavior.AllowGet);
         }
         else
             RedirectToAction("index", "backend");
         return Json("[]", JsonRequestBehavior.AllowGet);
 }
 public JsonResult GetPhoto()
 {
     string jsonData = "[]";
         IPhoto _cls = new PhotoBO();
         var data = _cls.GetData(_session.LangID, true);
         if (data != null)
             jsonData = new JavaScriptSerializer().Serialize(data);
         return Json(jsonData, JsonRequestBehavior.AllowGet);
 }
 public JsonResult DeletePhoto(long id)
 {
     if (_session.IsLogin && _session.IsStore && _session.IsAdmin)
         {
             string jsonData = "[]";
             IPhoto _cls = new PhotoBO();
             var data = _cls.DeletePhoto(id);
             jsonData = new JavaScriptSerializer().Serialize(data);
             return Json(jsonData, JsonRequestBehavior.AllowGet);
         }
         else
             RedirectToAction("index", "admin");
         return Json("[]", JsonRequestBehavior.AllowGet);
 }
 public ActionResult CreateVideo(long id)
 {
     ViewBag.ID = id;
         if (_session.IsLogin && _session.IsStore && _session.IsAdmin)
         {
             IPhoto cls = new PhotoBO();
             var data = cls.GetVideoByID(_session.LangID, id);
             if (data != null)
             {
                 ViewBag.Name = data.Title;
                 ViewBag.Description = data.Description;
                 ViewBag.Video = data.Video;
                 ViewBag.IsActive = data.IsActive;
             }
             else
             {
                 ViewBag.Name = "";
                 ViewBag.Description = "";
                 ViewBag.Video = "";
                 ViewBag.IsActive = true;
             }
             return View();
         }
         else
             return RedirectToAction("index", "admin");
 }
Exemple #23
0
 public ActionResult Photo(long id)
 {
     List<vw_PhotoDetail> data = new List<vw_PhotoDetail>();
         IPhoto _cls = new PhotoBO();
         data = _cls.GetPhotoDetail(_session.LangID, id);
         return PartialView(data);
 }
 public JsonResult DeletePhoto(int id)
 {
     if (_session.IsLogin)
     {
         PhotoBO _cls = new PhotoBO();
         var IsResult = _cls.Delete(id);
         return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet);
     }
     else
         RedirectToAction("index", "admin");
     return Json(new { IsOk = false }, JsonRequestBehavior.AllowGet);
 }