Ejemplo n.º 1
0
        public AlbumAddItemViewModel(Album album)
        {
            if (album != null)
            {
                AlbumId = album.Id;
                AlbumTitle = album.Title;

                UserId = album.UserId;
                GroupId = album.GroupId;
            }
        }
Ejemplo n.º 2
0
        public AlbumCreateEditViewModel(Album album)
        {
            if (album != null)
            {
                AlbumId = album.Id;
                Title = album.Title;
                Description = album.Description;
                IsOpen = album.IsOpen;

                GroupId = album.GroupId;
                UserId = album.UserId;
            }
        }
Ejemplo n.º 3
0
        public AlbumViewModel(Album album)
        {
            if (album == null)
                return;

            Id = album.Id;
            GroupId = album.GroupId;
            UserId = album.UserId;
            Title = album.Title;
            Description = album.Description;
            ChangeDate = album.ChangeDate;
            IsOpen = album.IsOpen;
            IsEmpty = album.Items.Count == 0;

            Items = album.Items.Select(x => new AlbumItemViewModel(x)).ToList();
            AddItem = new AlbumAddItemViewModel(album);
        }
Ejemplo n.º 4
0
        public static void DeleteAlbum(UserContainer currContext, Album album)
        {
            if (currContext != null)
            {
                if (album.GroupId.HasValue)
                {
                    var gm = GroupService.UserInGroup(currContext.Id, album.GroupId.Value, true);
                    if (gm.State != (byte)GroupMemberState.Moderator)
                        throw new BusinessLogicException("Только модераторы могут удалить альбом группы");
                }
                else if (album.UserId.HasValue)
                {
                    if (album.UserId != currContext.Id)
                        throw new BusinessLogicException("Нельзя удалить чужой альбом");
                }
                else
                    throw new BusinessLogicException("Альбом ни к чему не привязан");
            }

            DataService.PerThread.AlbumSet.DeleteObject(album);
            DataService.PerThread.SaveChanges();
        }
Ejemplo n.º 5
0
        public static Album CreateAlbum(Guid? groupId, Guid? userId, string title, string description, bool isOpen)
        {
            var album = new Album
            {
                GroupId = groupId,
                UserId = userId,
                Title = title,
                Description = description,
                ChangeDate = DateTime.Now,
                IsOpen = isOpen
            };

            DataService.PerThread.AlbumSet.AddObject(album);
            DataService.PerThread.SaveChanges();

            return album;
        }
Ejemplo n.º 6
0
        private void FixupAlbum(Album previousValue)
        {
            if (previousValue != null && previousValue.Items.Contains(this))
            {
                previousValue.Items.Remove(this);
            }

            if (Album != null)
            {
                if (!Album.Items.Contains(this))
                {
                    Album.Items.Add(this);
                }
                if (AlbumId != Album.Id)
                {
                    AlbumId = Album.Id;
                }
            }
        }