public ActionResult DeleteItem(string id, string movie, string returnurl)
 {
     if (!AlbumManager.Exist(id))
     {
         return(RedirectToAction("NotFound", "Error"));
     }
     AlbumManager.Minus(id, movie);
     return(RedirectToLocal(returnurl));
 }
        public ActionResult Edit(string id)
        {
            if (!AlbumManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ManageAlbumViewModel album = new ManageAlbumViewModel(_db.tbl_Album.SingleOrDefault(s => s.album_Id == id));

            return(View(album));
        }
        public ActionResult Delete(string id, string returnurl)
        {
            if (!AlbumManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ViewBag.ReturnUrl = returnurl;
            ManageAlbumViewModel album = new ManageAlbumViewModel(_db.tbl_Album.SingleOrDefault(s => s.album_Id == id));

            return(View(album));
        }
Exemple #4
0
 public ActionResult Cancel(string target, int type, string returnurl)
 {
     if (type <= 0 || type >= 7)
     {
         return(RedirectToAction("NotFound", "Error"));
     }
     else
     {
         if (type == 1 || type == 2 || type == 3)
         {
             if (!MovieManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 4)
         {
             if (!CelebManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 5)
         {
             if (!ResManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 6)
         {
             if (!AskManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else
         {
             if (!AlbumManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
     }
     if (User.Identity.Name != null)
     {
         MarkManager.Cancel(target, AccountManager.GetId(User.Identity.Name), type);
     }
     return(Redirect(returnurl));
 }
 public ActionResult Create(string target, int type, string returnurl)
 {
     if (type <= 0 || type >= 7)
     {
         return(RedirectToAction("NotFound", "Error"));
     }
     else
     {
         if (type == 1 || type == 2 || type == 3)
         {
             if (!MovieManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 4)
         {
             if (!CelebManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 5)
         {
             if (!ResManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 6)
         {
             if (!AskManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else
         {
             if (!AlbumManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
     }
     if (CookieHepler.GetCookie("user") != null)
     {
         MarkManager.Create(target, AccountManager.GetId(CookieHepler.GetCookie("user")), type);
     }
     return(Redirect(returnurl));
 }
        public ActionResult DeleteConfirm(string id)
        {
            if (!AlbumManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            string oldCover = _db.tbl_Album.SingleOrDefault(a => a.album_Id == id).album_Cover;

            if (oldCover != "Album_1.jpg")
            {
                ImageManager.Delete(Server.MapPath("~/Content/Album/" + oldCover));
            }
            AlbumManager.Delete(id);
            return(RedirectToAction("Index"));
        }
        //
        // GET: /Album/Detail/
        public ActionResult Detail(string id, int page = 1)
        {
            if (!AlbumManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            tbl_Album      tblalbum = _db.tbl_Album.SingleOrDefault(s => s.album_Id == id);
            AlbumViewModel album    = new AlbumViewModel(tblalbum);

            if (tblalbum.album_User == AccountManager.GetId(CookieHepler.GetCookie("user")))
            {
                album.IsCreator = true;
            }
            if (User.Identity.IsAuthenticated)
            {
                if (_db.tbl_Mark.SingleOrDefault(f => f.mark_Target == id && f.mark_User == AccountManager.GetId(CookieHepler.GetCookie("user")) && f.mark_Type == 7) != null)
                {
                    album.HasFollow = true;
                }
            }

            List <AlbumItemViewModel> allItem = new List <AlbumItemViewModel>();

            //album.Items = new List<AlbumItemViewModel>();
            allItem     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <AlbumItemViewModel> >(album.ItemJson);
            album.Count = allItem.Count;
            album.Items = allItem.Skip((page - 1) * album.ItemSize).Take(album.ItemSize).ToList();
            foreach (var item in album.Items)
            {
                item.MovieInfo = new MovieViewModel(_db.tbl_Movie.SingleOrDefault(m => m.movie_Id == item.Movie));
            }

            album.Page        = page;
            album.PagingCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(album.Count) / album.ItemSize));

            if (page > album.PagingCount && album.Items.Count > 0)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            AlbumManager.Visit(id);
            return(View(album));
        }