Ejemplo n.º 1
0
        public AlbumsViewModel(User user, Group group)
        {
            GroupAlbums = new List <AlbumViewModel>();
            UserAlbums  = new List <AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum  = new AlbumCreateEditViewModel();

            if (group != null)
            {
                GroupId     = group.Id;
                GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateGroupAlbum = new AlbumCreateEditViewModel(group);
            }

            if (user != null)
            {
                UserId     = user.Id;
                UserAlbums = user.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateUserAlbum = new AlbumCreateEditViewModel(user);
            }

            Albums = GroupAlbums.Union(UserAlbums).ToList();
        }
Ejemplo n.º 2
0
        public AlbumsViewModel(User user, Group group)
        {
            GroupAlbums = new List<AlbumViewModel>();
            UserAlbums = new List<AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum = new AlbumCreateEditViewModel();

            if (group != null)
            {
                GroupId = group.Id;
                GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateGroupAlbum = new AlbumCreateEditViewModel(group);
            }

            if (user != null)
            {
                UserId = user.Id;
                UserAlbums = user.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateUserAlbum = new AlbumCreateEditViewModel(user);
            }

            Albums = GroupAlbums.Union(UserAlbums).ToList();
        }
Ejemplo n.º 3
0
        public AlbumsViewModel()
        {
            Albums = new List<AlbumViewModel>();
            GroupAlbums = new List<AlbumViewModel>();
            UserAlbums = new List<AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum = new AlbumCreateEditViewModel();
        }
Ejemplo n.º 4
0
        public AlbumsViewModel()
        {
            Albums      = new List <AlbumViewModel>();
            GroupAlbums = new List <AlbumViewModel>();
            UserAlbums  = new List <AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum  = new AlbumCreateEditViewModel();
        }
Ejemplo n.º 5
0
        public AlbumsViewModel(User user)
        {
            GroupAlbums = new List<AlbumViewModel>();
            UserAlbums = new List<AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum = new AlbumCreateEditViewModel();

            if (user != null)
            {
                UserId = user.Id;
                UserAlbums = user.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateUserAlbum = new AlbumCreateEditViewModel(user);
            }

            Albums = UserAlbums;
        }
Ejemplo n.º 6
0
        public AlbumsViewModel(User user)
        {
            GroupAlbums = new List <AlbumViewModel>();
            UserAlbums  = new List <AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum  = new AlbumCreateEditViewModel();

            if (user != null)
            {
                UserId     = user.Id;
                UserAlbums = user.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateUserAlbum = new AlbumCreateEditViewModel(user);
            }

            Albums = UserAlbums;
        }
Ejemplo n.º 7
0
        public AlbumsViewModel(Group group)
        {
            GroupAlbums = new List<AlbumViewModel>();
            UserAlbums = new List<AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum = new AlbumCreateEditViewModel();

            if (group != null)
            {
                GroupId = group.Id;
                GroupUrl = group.Url;
                GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateGroupAlbum = new AlbumCreateEditViewModel(group);
            }

            Albums = GroupAlbums;
        }
Ejemplo n.º 8
0
        public AlbumsViewModel(Group group)
        {
            GroupAlbums = new List <AlbumViewModel>();
            UserAlbums  = new List <AlbumViewModel>();

            CreateGroupAlbum = new AlbumCreateEditViewModel();
            CreateUserAlbum  = new AlbumCreateEditViewModel();

            if (group != null)
            {
                GroupId     = group.Id;
                GroupUrl    = group.Url;
                GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList();

                CreateGroupAlbum = new AlbumCreateEditViewModel(group);
            }

            Albums = GroupAlbums;
        }
Ejemplo n.º 9
0
        public ActionResult Edit(AlbumCreateEditViewModel model)
        {
            if (!Request.IsAuthenticated)
                throw new AuthenticationException();

            if (!ModelState.IsValid)
                return View(model);

            var album = AlbumService.EditAlbum(UserContext.Current, model.AlbumId, model.Title, model.Description, model.IsOpen);

            return RedirectToAction("index", new { id = album.Id });
        }
Ejemplo n.º 10
0
        public ActionResult Create(AlbumCreateEditViewModel model)
        {
            if (!Request.IsAuthenticated)
                throw new AuthenticationException();

            if (!ModelState.IsValid)
                return View(model);

            var album = AlbumService.CreateAlbum(model.GroupId, model.UserId, model.Title, model.Description, model.IsOpen);

            if (Request.UrlReferrer != null && Request.UrlReferrer.Segments[2] == "albumsforeditor")
                return RedirectToAction("foreditor", "album", new { id = album.Id });

            return RedirectToAction("index", new { id = album.Id });
        }
Ejemplo n.º 11
0
        public ActionResult Create(string id)
        {
            if (!Request.IsAuthenticated)
                throw new AuthenticationException();

            AlbumCreateEditViewModel model;

            if (string.IsNullOrEmpty(id))
            {
                var user = DataService.PerThread.BaseUserSet.OfType<User>().SingleOrDefault(x => x.Id == UserContext.Current.Id);
                if (user == null)
                    throw new BusinessLogicException("Перезайдите");

                model = new AlbumCreateEditViewModel(user);
            }
            else
            {
                var group = GroupService.GetGroupByLabelOrId(id);

                var gm = GroupService.UserInGroup(UserContext.Current.Id, group, true);

                if (gm.State != (byte)GroupMemberState.Moderator)
                    throw new BusinessLogicException("Только модераторы могут создавать альбомы в группах");

                model = new AlbumCreateEditViewModel(group);
            }

            return View(model);
        }