예제 #1
0
 public IHttpActionResult AddNewAlbum([FromBody] AddAlbumPL newAlbum)
 {
     try
     {
         _bllFactory.AlbumBll.AddNewAlbum(newAlbum);
         return(Ok());
     }
     catch (Exception ex)
     {
         throw new ErrorOwnException("Ошибка при добавлении альбома" + ex.Message);
     }
 }
예제 #2
0
        public void AddNewAlbum(AddAlbumPL data)
        {
            Album    newAlbum  = new Album();
            DateTime dateValue = new DateTime(Convert.ToInt32(data.Album.Year), 01, 01);

            newAlbum.Year = dateValue;
            newAlbum.Name = data.Album.Name;
            foreach (var track in Mapper.Map <IList <TrackDTO>, IList <Track> >(data.TrackList))
            {
                newAlbum.Tracks = new Collection <Track> {
                    track
                }
            }
            ;;
            _dalFactory.Album.Add(newAlbum);
        }
    }