public IActionResult AddAlbum(AlbumPostIndexModel model)
        {
            if (model == null)
            {
                RedirectToAction("ArtistInfo", new { id = model.Artist.Id });
            }

            var artistModel = model.Artist;
            var albumModel  = model.Album;

            //add the album - populate an Album instance with values from the form
            var album = new Album
            {
                Id         = albumModel.Id,
                Name       = albumModel.Name,
                YrReleased = albumModel.YrReleased
            };

            _album.Add(album);

            _albumSong.Add(album.Id, artistModel.Id, 0, 0);

            return(RedirectToAction("Index", "AlbumMod",
                                    new { artistId = artistModel.Id, albumId = album.Id }));
        }
Example #2
0
        public ActionResult Add(Album model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var album = _albumService.Add(model);

            TempData["Success"] = $"{album.Name} was created";

            var b = Request.Browser;

            return(RedirectToRoute("ArtistDetails", new { id = model.ArtistId }));
        }
        public ActionResult Create([Bind(Include = "id,title,created")] AlbumViewModel albumModel, int language_id)
        {
            ViewBag.language_id = new SelectList(languageHandler.All().
                                                 Select(c => new { id = c.id, title = c.title }), "id", "title");

            if (ModelState.IsValid)
            {
                Mapper.Initialize(cfg => cfg.CreateMap <AlbumViewModel, Albums>());
                DateTime date = DateTime.Now;
                albumModel.created     = date;
                albumModel.language_id = language_id;
                Albums album = Mapper.Map <AlbumViewModel, Albums>(albumModel);
                albumHandler.Add(album);
                return(RedirectToAction("Index"));
            }


            return(View(albumModel));
        }
Example #4
0
            private static void AddChildObjects(IAlbum album)
            {
            if (album == null)
                throw new ArgumentNullException("album");

            #region Add child albums

            foreach (int albumId in GetDataProvider().Album_GetChildAlbumIdsById(album.Id))
            {
                album.Add(CreateAlbumInstance(albumId, album.GalleryId));
            }

            #endregion

            #region Add child media objects

            foreach (MediaObjectDto moDto in GetDataProvider().Album_GetChildMediaObjectsById(album.Id, album.AllowMetadataLoading))
            {
                album.Add(LoadMediaObjectInstance(moDto, album));
            }

            #endregion

            album.AreChildrenInflated = true;
            }
Example #5
0
 /// <summary>
 /// 保存添加数据 Add(AlbumInfo entity)
 /// </summary>
 /// <param name="entity">实体类(AlbumInfo)</param>
 ///<returns>返回新增的ID</returns>
 public void Add(AlbumInfo entity)
 {
     _album.Add(entity);
 }
Example #6
0
            private static void AddChildObjects(IAlbum album)
            {
            if (album == null)
                throw new ArgumentNullException("album");

            #region Add child albums

            foreach (int albumId in GetDataProvider().Album_GetChildAlbumIdsById(album.Id))
            {
                album.Add(CreateAlbumInstance(albumId, album.GalleryId));
            }

            #endregion

            #region Add child media objects

            foreach (MediaObjectDto moDto in GetDataProvider().Album_GetChildMediaObjectsById(album.Id))
            {
                // SQL:
                // SELECT
                //  MediaObjectID, FKAlbumID, Title, HashKey, ThumbnailFilename, ThumbnailWidth, ThumbnailHeight,
                //  ThumbnailSizeKB, OptimizedFilename, OptimizedWidth, OptimizedHeight, OptimizedSizeKB,
                //  OriginalFilename, OriginalWidth, OriginalHeight, OriginalSizeKB, ExternalHtmlSource, ExternalType, mo.Seq,
                //  CreatedBy, DateAdded, LastModifiedBy, DateLastModified, IsPrivate
                // FROM [gs_MediaObject]
                // WHERE FKAlbumID = @AlbumId
                album.Add(LoadMediaObjectInstance(moDto, album));
            }

            #endregion

            album.AreChildrenInflated = true;
            }
Example #7
0
		private static void AddChildObjects(IAlbum album)
		{
			#region Add child albums

			IDataReader dr = null;
			try
			{
				using (dr = Factory.GetDataProvider().Album_GetDataReaderChildAlbumsById(album.Id))
				{
					// SQL:
					// SELECT AlbumID
					// FROM Album
					// WHERE AlbumParentID = @AlbumId
					while (dr.Read())
					{
						album.Add(Factory.CreateAlbumInstance(Convert.ToInt32(dr[0], CultureInfo.InvariantCulture)));
					}
				}
			}
			finally
			{
				if (dr != null) dr.Close();
			}

			#endregion

			#region Add child media objects

			dr = null;
			try
			{
				using (dr = Factory.GetDataProvider().Album_GetDataReaderChildMediaObjectsById(album.Id))
				{
					// SQL:
					// SELECT 
					//  MediaObjectID, FKAlbumID, Title, HashKey, ThumbnailFilename, ThumbnailWidth, ThumbnailHeight, 
					//  ThumbnailSizeKB, OptimizedFilename, OptimizedWidth, OptimizedHeight, OptimizedSizeKB, 
					//  OriginalFilename, OriginalWidth, OriginalHeight, OriginalSizeKB, ExternalHtmlSource, ExternalType, mo.Seq, 
					//  CreatedBy, DateAdded, LastModifiedBy, DateLastModified, IsPrivate
					// FROM [gs_MediaObject]
					// WHERE FKAlbumID = @AlbumId
					while (dr.Read())
					{
						album.Add(Factory.LoadMediaObjectInstance((IDataRecord)dr, album));
					}
				}
			}
			finally
			{
				if (dr != null) dr.Close();
			}
			#endregion

			album.AreChildrenInflated = true;
		}