示例#1
0
        //Main page of the album
        public IActionResult Main(int id)
        {
            if (id == 1)
            {
                return(NotFound());         //"Public" album id, should not be displayer or found
            }
            var user  = _userManager.GetUserAsync(User).Result;
            var album = _service.GetAlbum(id);

            if (album == null)
            {
                return(NotFound());               //Album not found
            }
            ViewData["CanPost"]   = false;
            ViewData["CanManage"] = false;
            var channel = _channelService.GetChannel(album.ChannelId).Result;

            if (channel != null)
            {
                var channelUser = _channelService.GetChannelMember(user, channel).Result;
                if (channelUser == null)
                {
                    if (!album.VisibleToGuests)
                    {
                        return(RedirectToAction("Index", "Thread", new { id = 30 }));
                    }
                }
                else
                {
                    if (user.Id == channel.CreatorId || album.MembersCanPost)
                    {
                        ViewData["CanPost"] = true;
                        if (user.Id == channel.CreatorId)
                        {
                            ViewData["CanManage"] = true;
                        }
                    }
                }
            }
            var threads = BuildThreadList(album);
            var model   = new AlbumModel
            {
                AlbumId = album.Id,
                Title   = album.Title,
                Channel = channel,
                Threads = threads
            };

            return(View(model));
        }
示例#2
0
        public IActionResult NewAlbum(string id, string Title, bool NotVisible, bool NoPosting)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var channel = _service.GetChannel(id).Result;

            if (channel == null)
            {
                return(NotFound());
            }
            var user = _userManager.GetUserAsync(User).Result;

            if (user.Id == channel.CreatorId)
            {
                var album = _albumService.GetAlbum(channel, Title); //Check if an album with this title already exists in this channel
                if (album == null)
                {
                    var albumId = _albumService.CreateNewAlbum(channel, Title, NotVisible, NoPosting);
                    return(RedirectToAction("Main", "Album", new { id = albumId }));
                }
                else
                {
                    ViewData["channel"] = channel.Title;
                    ViewData["Exists"]  = true; //Displays a message that an album with this title already exists
                    return(View("CreateAlbum"));
                }
            }
            return(RedirectToAction("Index", "Thread", new { id = 30 }));
        }
示例#3
0
        public ActionResult <AlbumDto> GetAlbumById(int id)
        {
            loggerC.Information("Information is logged");
            loggerC.Debug("Debug log is logged");
            var album = _album.GetAlbum(id);

            if (album == null)
            {
                loggerC.Warning("Warning is logged");
                loggerC.Error("Not found");
                return(NotFound());
            }
            return(Ok(_mapper.Map <AlbumDto>(album)));
        }
示例#4
0
 public IActionResult Create(int albumId)
 {
     if (albumId != 1)
     {
         var album = _albumService.GetAlbum(albumId);
         if (album == null)
         {
             return(NotFound());
         }
         var channel       = _channelService.GetChannel(album.ChannelId).Result;
         var user          = _userManager.GetUserAsync(User).Result;
         var channelMember = _channelService.GetChannelMember(user, channel).Result;
         if (channelMember == null)
         {
             return(NotFound());
         }
         if (!(album.MembersCanPost || user.Id == channel.CreatorId))
         {
             return(NotFound());
         }
     }
     ViewData["albumId"] = albumId;
     return(View());
 }