Пример #1
0
        public int CreateNewAlbum(string email, string albumName, int totalTrack)
        {
            logic = new GeneralLogics();
            PurchaseRecordQueriesCommands purchaseCQ = new PurchaseRecordQueriesCommands();
            AlbumQueriesCommands          AlbumCQ    = new AlbumQueriesCommands();
            AuthQueriesCommands           AuthCQ     = new AuthQueriesCommands();

            Account account = AuthCQ.GetAccountByEmail(email);

            if (account != null)
            {
                var GetListOfUnUsedPurchase = purchaseCQ.GetUnUsedAlbumPurchaseRecordOf(account);
                if (GetListOfUnUsedPurchase.Count > 0)
                {
                    Album album = new Album();

                    album.Id                  = logic.CreateUniqueId();
                    album.Album_Name          = albumName;
                    album.Total_Track         = totalTrack;
                    album.Album_Creation_Date = logic.CurrentIndianTime();
                    album.Submitted_Track     = 0;
                    album.PurchaseTrack_RefNo = GetListOfUnUsedPurchase.First().Id;

                    var resultCreateAlbum = AlbumCQ.CreateAlbum(album);
                    if (resultCreateAlbum == 1)
                    {
                        var purchaseRecord = purchaseCQ.GetPurchaseRecordById(album.PurchaseTrack_RefNo);

                        purchaseRecord.Usage_Date = logic.CurrentIndianTime();
                        int resultPurchaseRecordUpdate = purchaseCQ.UpdatePurchaseRecord(purchaseRecord);

                        if (resultPurchaseRecordUpdate == 1)
                        {
                            //Album created, PurchaseRecord is modified with UsageDate. Operation Completed successfully
                            return(1);
                        }
                        else
                        {
                            //Internal error occured while updating the record in PurchaseRecord table.Operation failed
                            return(4);
                        }
                    }
                    else
                    {
                        //Album creation failed
                        return(3);
                    }
                }
                else
                {
                    //No purchase left to create an music album.
                    return(2);
                }
            }
            else
            {
                //No Account Found
                return(0);
            }
        }
Пример #2
0
        public int PurchaseSoloFor(string userEmail)
        {
            PurchaseRecordQueriesCommands PrCQ   = new PurchaseRecordQueriesCommands();
            AuthQueriesCommands           AuthCQ = new AuthQueriesCommands();
            var account = AuthCQ.GetAccountByEmail(userEmail);

            if (account != null)
            {
                logic = new GeneralLogics();
                var purchaseId = logic.CreateUniqueId();

                PurchaseRecord pr = new PurchaseRecord();

                pr.Id = purchaseId;
                pr.Purchased_Category = "solo";
                pr.Account_Id         = account.Id;
                pr.PurchaseDate       = logic.CurrentIndianTime();

                var result = PrCQ.AddPurchaseRecord(pr);

                if (result == 1)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                //Account not found
                return(2);
            }
        }
Пример #3
0
        public bool IsPurchaseExpired(Guid?purchaseId)
        {
            logic = new GeneralLogics();
            PurchaseRecordQueriesCommands prCQ = new PurchaseRecordQueriesCommands();

            return(prCQ.IsPurchaseExpired(purchaseId, logic.CurrentIndianTime()));
        }
Пример #4
0
        public int CreateNewEp(string email, string epName, int totalTrack)
        {
            logic = new GeneralLogics();
            PurchaseRecordQueriesCommands purchaseCQ = new PurchaseRecordQueriesCommands();
            EPQueriesCommands             EpCQ       = new EPQueriesCommands();
            AuthQueriesCommands           AuthCQ     = new AuthQueriesCommands();

            Account account = AuthCQ.GetAccountByEmail(email);

            if (account != null)
            {
                var GetListOfUnUsedPurchase = purchaseCQ.GetUnUsedEpPurchaseRecordOf(account);
                if (GetListOfUnUsedPurchase.Count > 0)
                {
                    ExtendedPlay ep = new ExtendedPlay();

                    ep.Id                  = logic.CreateUniqueId();
                    ep.Ep_Name             = epName;
                    ep.Total_Track         = totalTrack;
                    ep.Ep_Creation_Date    = logic.CurrentIndianTime();
                    ep.Submitted_Track     = 0;
                    ep.PurchaseTrack_RefNo = GetListOfUnUsedPurchase.First().Id;

                    var resultCreateEp = EpCQ.CreateEP(ep);
                    if (resultCreateEp == 1)
                    {
                        var purchaseRecord = purchaseCQ.GetPurchaseRecordById(ep.PurchaseTrack_RefNo);

                        purchaseRecord.Usage_Date = logic.CurrentIndianTime();
                        int resultPurchaseRecordUpdate = purchaseCQ.UpdatePurchaseRecord(purchaseRecord);

                        if (resultPurchaseRecordUpdate == 1)
                        {
                            //Ep created, PurchaseRecord is modified with UsageDate. Operation Completed successfully
                            return(1);
                        }
                        else
                        {
                            //Internal error occured while updating the record in PurchaseRecord table.Operation failed
                            return(4);
                        }
                    }
                    else
                    {
                        //Ep creation failed
                        return(3);
                    }
                }
                else
                {
                    //No purchase left to create an music Ep.
                    return(2);
                }
            }
            else
            {
                //No Account Found
                return(0);
            }
        }
Пример #5
0
        public Guid?GetFirstPurchaseIdForSoloOf(string email)
        {
            AuthQueriesCommands AuthCQ = new AuthQueriesCommands();
            var accountObject          = AuthCQ.GetAccountByEmail(email);

            if (accountObject != null)
            {
                PurchaseRecordQueriesCommands prCQ = new PurchaseRecordQueriesCommands();
                return(prCQ.GetUnUsedSoloPurchaseRecordOf(accountObject).First().Id);
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        public bool IsAccountContainsThisPurchase(string email, Guid?purchaseId)
        {
            AuthQueriesCommands AuthCQ = new AuthQueriesCommands();
            var accountObject          = AuthCQ.GetAccountByEmail(email);

            if (accountObject != null)
            {
                PurchaseRecordQueriesCommands prCQ = new PurchaseRecordQueriesCommands();
                return(prCQ.GetAllPurchaseRecordsOf(accountObject).Any(rec => rec.Id == purchaseId));
            }
            else
            {
                //No account found with this email
                return(false);
            }
        }
Пример #7
0
        public int CountOfSolosCanBeCreatedBy(string userEmail)
        {
            PurchaseRecordQueriesCommands purchaseCQ = new PurchaseRecordQueriesCommands();
            AuthQueriesCommands           AuthCQ     = new AuthQueriesCommands();

            Account account = AuthCQ.GetAccountByEmail(userEmail);

            if (account != null)
            {
                var GetListOfUnUsedPurchase = purchaseCQ.GetUnUsedSoloPurchaseRecordOf(account);

                //Returning the count of the unused purchase of Eps for the user
                return(GetListOfUnUsedPurchase.Count);
            }
            else
            {
                //No Account Found
                return(0);
            }
        }
Пример #8
0
        public int CountOfAlbumsAlreadyCreatedBy(string email)
        {
            PurchaseRecordQueriesCommands purchaseCQ = new PurchaseRecordQueriesCommands();
            AuthQueriesCommands           AuthCQ     = new AuthQueriesCommands();

            Account account = AuthCQ.GetAccountByEmail(email);

            if (account != null)
            {
                var GetListOfUnUsedPurchase = purchaseCQ.GetUsedAlbumPurchaseRecordOf(account);

                //Returning the count of the unused purchase of albums for the user
                return(GetListOfUnUsedPurchase.Count);
            }
            else
            {
                //No Account Found
                return(0);
            }
        }
Пример #9
0
        public int CreateNewTrackForSolo(Guid purchaseId, string TrackTitle, string ArtistName, bool ArtistAlreadyInSpotify, string ArtistSpotifyUrl, DateTime ReleaseDate, string Genre, string CopyrightClaimerName, string AuthorName, string ComposerName, string ArrangerName, string ProducerName, bool AlreadyHaveAnISRC, string ISRC_Number, int PriceTier, bool ExplicitContent, bool IsTrackInstrumental, string LyricsLanguage, string TrackZipFileLink, string ArtWork_Link)
        {
            byte ArtistSpotifyAppearance   = 1;
            byte PresenceOfISRCnumber      = 1;
            byte PresenceOfExplicitContent = 1;
            byte InstrumentalTrackPresence = 1;

            if (ArtistAlreadyInSpotify == false)
            {
                ArtistSpotifyAppearance = 0;
            }
            if (AlreadyHaveAnISRC == false)
            {
                PresenceOfISRCnumber = 0;
            }
            if (IsTrackInstrumental == false)
            {
                InstrumentalTrackPresence = 0;
            }
            if (ExplicitContent == false)
            {
                PresenceOfExplicitContent = 0;
            }
            SingleTrackDetail std   = new SingleTrackDetail();
            GeneralLogics     logic = new GeneralLogics();

            std.Id                     = logic.CreateUniqueId();
            std.TrackTitle             = TrackTitle;
            std.ArtistName             = ArtistName;
            std.ArtistAlreadyInSpotify = ArtistSpotifyAppearance;
            std.ArtistSpotifyUrl       = ArtistSpotifyUrl;
            std.ReleaseDate            = ReleaseDate;
            std.Genre                  = Genre;
            std.CopyrightClaimerName   = CopyrightClaimerName;
            std.AuthorName             = AuthorName;
            std.ComposerName           = ComposerName;
            std.ArrangerName           = ArrangerName;
            std.ProducerName           = ProducerName;
            std.AlreadyHaveAnISRC      = PresenceOfISRCnumber;
            std.ISRC_Number            = ISRC_Number;
            std.PriceTier              = PriceTier;
            std.ExplicitContent        = PresenceOfExplicitContent;
            std.IsTrackInstrumental    = InstrumentalTrackPresence;
            std.LyricsLanguage         = LyricsLanguage;
            std.TrackZipFileLink       = TrackZipFileLink;
            std.ArtworkFileLink        = ArtWork_Link.Trim();

            TrackQueriesCommands TrackCQ = new TrackQueriesCommands();
            //add single track
            var singleTrackSaveResult = TrackCQ.AddTrack(std);

            if (singleTrackSaveResult == 1)
            {
                //Link track with the SoloMaster table. Work on albumtrackMaster table
                SoloTrackMaster stm = new SoloTrackMaster();

                stm.Id                  = logic.CreateUniqueId();
                stm.Track_Id            = std.Id;
                stm.PurchaseTrack_RefNo = purchaseId;
                stm.Submitted_At        = logic.CurrentIndianTime();
                //Status = pending
                stm.StoreSubmissionStatus = 2;

                var stmSaveResult = TrackCQ.AddtoSoloTrackMaster(stm);

                if (stmSaveResult == 1)
                {
                    PurchaseRecordQueriesCommands PurchaseCQ = new PurchaseRecordQueriesCommands();
                    PurchaseRecord pr = PurchaseCQ.GetPurchaseRecordById(purchaseId);
                    if (pr != null)
                    {
                        pr.Usage_Date     = logic.CurrentIndianTime();
                        pr.Usage_Exp_Date = logic.CurrentIndianTime().AddHours(24);
                        var purchaseEditResult = PurchaseCQ.UpdatePurchaseRecord(pr);
                        if (purchaseEditResult == 1)
                        {
                            //purchase expire date set
                            return(1);
                        }
                        else
                        {
                            //Error while setting the expire date
                            return(4);
                        }
                    }
                    else
                    {
                        //error while fetching the purchase record of the album
                        return(3);
                    }
                }
                else
                {
                    //Error occured while adding soloTrackMaster record
                    return(2);
                }
            }
            else
            {
                //Error occured while saving single track to the database
                return(0);
            }
        }
Пример #10
0
        public int CreateNewTrackForEp(Guid epId, string TrackTitle, string ArtistName, bool ArtistAlreadyInSpotify, string ArtistSpotifyUrl, DateTime ReleaseDate, string Genre, string CopyrightClaimerName, string AuthorName, string ComposerName, string ArrangerName, string ProducerName, bool AlreadyHaveAnISRC, string ISRC_Number, int PriceTier, bool ExplicitContent, bool IsTrackInstrumental, string LyricsLanguage, string TrackZipFileLink, string ArtWork_Link)
        {
            EPQueriesCommands             EpCQ       = new EPQueriesCommands();
            PurchaseRecordQueriesCommands PurchaseCQ = new PurchaseRecordQueriesCommands();

            logic = new GeneralLogics();

            var epObject = EpCQ.GetEpById(epId);

            if (epObject != null)
            {
                if (PurchaseCQ.GetPurchaseRecordById(epObject.PurchaseTrack_RefNo).Usage_Exp_Date < logic.CurrentIndianTime())
                {
                    //Can't add more track in the album as purchase expired
                    return(7);
                }

                if (epObject.Total_Track <= epObject.Submitted_Track)
                {
                    //can't add more track in the album as the album is full
                    return(8);
                }

                byte ArtistSpotifyAppearance   = 1;
                byte PresenceOfISRCnumber      = 1;
                byte PresenceOfExplicitContent = 1;
                byte InstrumentalTrackPresence = 1;

                if (ArtistAlreadyInSpotify == false)
                {
                    ArtistSpotifyAppearance = 0;
                }
                if (AlreadyHaveAnISRC == false)
                {
                    PresenceOfISRCnumber = 0;
                }
                if (IsTrackInstrumental == false)
                {
                    InstrumentalTrackPresence = 0;
                }
                if (ExplicitContent == false)
                {
                    PresenceOfExplicitContent = 0;
                }
                SingleTrackDetail std = new SingleTrackDetail();

                std.Id                     = logic.CreateUniqueId();
                std.TrackTitle             = TrackTitle;
                std.ArtistName             = ArtistName;
                std.ArtistAlreadyInSpotify = ArtistSpotifyAppearance;
                std.ArtistSpotifyUrl       = ArtistSpotifyUrl;
                std.ReleaseDate            = ReleaseDate;
                std.Genre                  = Genre;
                std.CopyrightClaimerName   = CopyrightClaimerName;
                std.AuthorName             = AuthorName;
                std.ComposerName           = ComposerName;
                std.ArrangerName           = ArrangerName;
                std.ProducerName           = ProducerName;
                std.AlreadyHaveAnISRC      = PresenceOfISRCnumber;
                std.ISRC_Number            = ISRC_Number;
                std.PriceTier              = PriceTier;
                std.ExplicitContent        = PresenceOfExplicitContent;
                std.IsTrackInstrumental    = InstrumentalTrackPresence;
                std.LyricsLanguage         = LyricsLanguage;
                std.TrackZipFileLink       = TrackZipFileLink;
                std.ArtworkFileLink        = ArtWork_Link.Trim();

                TrackQueriesCommands TrackCQ = new TrackQueriesCommands();
                //add single track
                var singleTrackSaveResult = TrackCQ.AddTrack(std);

                if (singleTrackSaveResult == 1)
                {
                    //Link track with the album. Work on albumtrackMaster table
                    EpTrackMaster etm = new EpTrackMaster();

                    etm.Id           = logic.CreateUniqueId();
                    etm.Ep_Id        = epId;
                    etm.Track_Id     = std.Id;
                    etm.Submitted_At = logic.CurrentIndianTime();
                    //Status = pending
                    etm.StoreSubmissionStatus = 2;

                    var etmSaveResult = TrackCQ.AddtoEpTrackMaster(etm);

                    if (etmSaveResult == 1)
                    {
                        //increment the number of the submitted track for the album
                        epObject.Submitted_Track = epObject.Submitted_Track + 1;

                        var epEditResult = EpCQ.EditEpDetails(epObject);

                        if (epEditResult == 1)
                        {
                            //if it's the first track of the album then set purchase record usage expire time
                            epObject = EpCQ.GetEpById(epId);
                            if (epObject != null)
                            {
                                if (epObject.Submitted_Track == 1)
                                {
                                    PurchaseRecord pr = PurchaseCQ.GetPurchaseRecordById(epObject.PurchaseTrack_RefNo);
                                    if (pr != null)
                                    {
                                        pr.Usage_Exp_Date = logic.CurrentIndianTime().AddHours(24);
                                        var purchaseEditResult = PurchaseCQ.UpdatePurchaseRecord(pr);
                                        if (purchaseEditResult == 1)
                                        {
                                            //purchase expire date set
                                            return(1);
                                        }
                                        else
                                        {
                                            //Error while setting the expire date
                                            return(11);
                                        }
                                    }
                                    else
                                    {
                                        //error while fetching the purchase record of the album
                                        return(10);
                                    }
                                }
                                return(1);
                            }
                            else
                            {
                                //error while fetching the album
                                return(9);
                            }
                        }
                        else
                        {
                            //Error occured while updating album record
                            return(6);
                        }
                    }
                    else
                    {
                        //Error occured while adding albumTrackMaster record
                        return(5);
                    }
                }
                else
                {
                    //Error occured while saving single track to the database
                    return(4);
                }
            }
            else
            {
                //No album found with the provided Album Id
                return(0);
            }
        }