public IHttpActionResult AddNewAlbum([FromBody] AddAlbumPL newAlbum) { try { _bllFactory.AlbumBll.AddNewAlbum(newAlbum); return(Ok()); } catch (Exception ex) { throw new ErrorOwnException("Ошибка при добавлении альбома" + ex.Message); } }
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); } }