コード例 #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 CountOfAlbumsCanBeCreatedBy(string email)
        {
            PurchaseRecordQueriesCommands purchaseCQ = new PurchaseRecordQueriesCommands();
            AuthQueriesCommands           AuthCQ     = new AuthQueriesCommands();

            Account account = AuthCQ.GetAccountByEmail(email);

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

                //Returning the count of the unused purchase of albums for the user
                return(GetListOfUnUsedPurchase.Count);
            }
            else
            {
                //No Account Found
                return(0);
            }
        }