コード例 #1
0
        public int CreateAlbum(AlbumCreationViewModel album)
        {
            int albumId;

            var label       = _organizationLabelRepository.GetById(album.PublisherLabelId);
            var isrcSeries  = _organizationIsrcSeriesRepository.GetById(album.Publisher.IsrcSeriesId);
            var currentDate = DateTime.Now;

            var productPackage = new media_product_package
            {
                albumtitle           = album.BasicInfo.AlbumTitle,
                albumid              = 0,
                physicallocation     = "",
                labelid              = album.PublisherLabelId,
                cataloguenumber      = "",
                releasetypecode      = "0",
                countryofproduction  = label.countrycode,
                countryofpublication = label.countrycode,
                releasedate          = currentDate,
                packagestatusid      = 4,
                numberoftracks       = album.BasicInfo.NumberOfTracks,
                formattypeid         = 2,
                comment              = album.ReviewComment,
                updatedby            = "User",
                updatedon            = currentDate,
                createdby            = "User",
                createdon            = currentDate,
                mainartistid         = album.BasicInfo.MainArtistId
            };

            _albumRepository.Add(productPackage);

            _unitOfWork.Commit();

            albumId = productPackage.id;

            foreach (var song in album.Songs)
            {
                // If newly created song has already been created with the same isrc.
                if (song.Id == -1 && _mediaRecordingRepository.Get(m => m.isrc == song.Isrc) != null)
                {
                    throw new DuplicateNameException("Isrc provided does already exist.");
                }

                int recordingId;

                if (song.Id == -1)
                {
                    //   1.3. Create media_recording (s)
                    var recording = new media_recording
                    {
                        isrc                 = song.Isrc,
                        recordingtitle       = song.Name,
                        workingtitle         = song.Name,
                        recordingcountrycode = label.countrycode,
                        statusid             = 4,
                        updatedby            = "User",
                        updatedon            = currentDate,
                        createdby            = "User",
                        createdon            = currentDate,
                        recordingdate        = song.RecordingDate,
                        duration             = song.Length,
                        mainartist           = album.BasicInfo.MainArtistId,
                        markedfordeletion    = false
                    };

                    _mediaRecordingRepository.Add(recording);
                    _unitOfWork.Commit();

                    recordingId = recording.id;
                }
                else
                {
                    recordingId = song.Id;
                }

                //   1.4. Create media_product (s)
                _songRepository.Add(new media_product
                {
                    isrc                = song.Isrc,
                    recordingid         = recordingId,
                    title               = song.Name,
                    tracknumber         = song.Number,
                    sidenumber          = 1,
                    labelid             = album.PublisherLabelId,
                    cataloguenumber     = "",
                    mediaproducttypeid  = 1,
                    packageid           = albumId,
                    releasedate         = currentDate,
                    countryofproduction = label.countrycode,
                    statusid            = 4,
                    updatedby           = "User",
                    updatedon           = currentDate,
                    createdby           = "User",
                    createdon           = currentDate,
                    is_deleted          = false
                });

                //   1.5. Add to recording_party
                song.Performers.ForEach(performer => _recordingPartyRepository.Add(new recording_party
                {
                    recordingid    = recordingId,
                    partyrealid    = performer.Id,
                    rolecode       = performer.Role.RoleCode,
                    instrumentcode = performer.Instrument.IdCode,
                    updatedby      = "User",
                    updatedon      = currentDate,
                    createdby      = "User",
                    createdon      = currentDate,
                    status         = 2
                }));
            }

            isrcSeries.updatedon            = currentDate;
            isrcSeries.updatedby            = "User";
            isrcSeries.isrc_lastusednumber += 100;
            isrcSeries.isrc_lastusedyear    = DateTime.Now.Year;

            _organizationIsrcSeriesRepository.Update(isrcSeries);

            //   1.6. Commit changes
            _unitOfWork.Commit();

            return(albumId);
        }
コード例 #2
0
        public int PublishProjectById(int projectId, ProjectReviewViewModel reviewModel)
        {
            var projectToUpdate = _projectMasterRepository.GetById(projectId);
            int albumId         = 0;

            if (projectToUpdate != null)
            {
                //   1.1. Update project status
                projectToUpdate.statuscode      = "PUBLISHED";
                projectToUpdate.updatedby       = "User";
                projectToUpdate.updatedon       = DateTime.Now;
                projectToUpdate.reviewedby      = "User";
                projectToUpdate.reviewedok      = true;
                projectToUpdate.reviewedon      = DateTime.Now;
                projectToUpdate.reviewedcomment = reviewModel.ReviewComment;

                _projectMasterRepository.Update(projectToUpdate);

                var label       = _organizationLabelRepository.GetById(reviewModel.LabelId);
                var isrcSeries  = _organizationIsrcSeriesRepository.GetById(reviewModel.IsrcSeriesId);
                var currentDate = DateTime.Now;

                //   1.2. Create media_product_package
                var productPackage = new media_product_package
                {
                    albumtitle           = projectToUpdate.projectname,
                    albumid              = 0,
                    physicallocation     = "",
                    labelid              = reviewModel.LabelId,
                    cataloguenumber      = "",
                    releasetypecode      = "0",
                    countryofproduction  = label.countrycode,
                    countryofpublication = label.countrycode,
                    releasedate          = currentDate,
                    packagestatusid      = 4,
                    numberoftracks       = _projectTrackRepository.GetMany(pt => pt.projectid == projectId).Count(),
                    formattypeid         = 2,
                    comment              = reviewModel.ReviewComment,
                    updatedby            = "User",
                    updatedon            = currentDate,
                    createdby            = "User",
                    createdon            = currentDate,
                    mainartistid         = projectToUpdate.mainartistid
                };
                _albumRepository.Add(productPackage);

                _unitOfWork.Commit();

                albumId = productPackage.id;

                var projectTracks  = _projectTrackRepository.GetMany(pt => pt.projectid == projectId).ToList();
                var lastUsedNumber = isrcSeries.isrc_lastusednumber;

                foreach (var track in projectTracks)
                {
                    string isrc;

                    if (string.IsNullOrEmpty(track.isrc))
                    {
                        isrc = IsrcHelper.GenerateIsrcNumber(isrcSeries.isrc_countrypart,
                                                             isrcSeries.isrc_organizationpart,
                                                             isrcSeries.isrc_lastusedyear, ++lastUsedNumber);
                    }
                    else
                    {
                        isrc = track.isrc;
                    }

                    // Update track isrc as well.
                    track.isrc = isrc;
                    _projectTrackRepository.Update(track);

                    int recordingId;

                    if (track.recordingid != null && track.recordingid != -1)
                    {
                        recordingId = track.recordingid.Value;
                    }
                    else
                    {
                        //   1.3. Create media_recording (s)
                        var recording = new media_recording
                        {
                            isrc                 = isrc,
                            recordingtitle       = track.trackname,
                            workingtitle         = track.trackname,
                            recordingcountrycode = label.countrycode,
                            statusid             = 4,
                            updatedby            = "User",
                            updatedon            = currentDate,
                            createdby            = "User",
                            createdon            = currentDate,
                            recordingdate        = track.createdon,
                            duration             = track.duration,
                            mainartist           = projectToUpdate.mainartistid,
                            markedfordeletion    = false,
                            projecttrackid       = track.id
                        };

                        _mediaRecordingRepository.Add(recording);

                        _unitOfWork.Commit();

                        recordingId = recording.id;
                    }

                    //   1.4. Create media_product (s)
                    _songRepository.Add(new media_product
                    {
                        isrc                = isrc,
                        recordingid         = recordingId,
                        title               = track.trackname,
                        tracknumber         = track.trackorder,
                        sidenumber          = 1,
                        labelid             = reviewModel.LabelId,
                        cataloguenumber     = "",
                        mediaproducttypeid  = 1,
                        packageid           = albumId,
                        releasedate         = currentDate,
                        countryofproduction = label.countrycode,
                        statusid            = 4,
                        updatedby           = "User",
                        updatedon           = currentDate,
                        createdby           = "User",
                        createdon           = currentDate,
                        is_deleted          = false
                    });

                    var projectTrackArtists = _projectTrackArtistRepository.GetMany(p => p.projecttrackid == track.id).ToList();

                    //   1.5. Add to recording_party
                    projectTrackArtists.ForEach(pta => _recordingPartyRepository.Add(new recording_party
                    {
                        recordingid       = recordingId,
                        partyrealid       = pta.partyrealid,
                        rolecode          = pta.rolecode,
                        instrumentcode    = pta.instrumentcode,
                        artistpseudonymid = pta.artistpseudonymid,
                        updatedby         = "User",
                        updatedon         = currentDate,
                        createdby         = "User",
                        createdon         = currentDate,
                        status            = 2
                    }));
                }

                isrcSeries.updatedon            = currentDate;
                isrcSeries.updatedby            = "User";
                isrcSeries.isrc_lastusednumber += 100;
                isrcSeries.isrc_lastusedyear    = DateTime.Now.Year;

                _organizationIsrcSeriesRepository.Update(isrcSeries);

                //   1.6. Commit changes
                _unitOfWork.Commit();
            }

            return(albumId);
        }