Example #1
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);
            }
        }
Example #2
0
        public int CountOfEpsCanBeCreatedBy(string email)
        {
            PurchaseRecordQueriesCommands purchaseCQ = new PurchaseRecordQueriesCommands();
            AuthQueriesCommands           AuthCQ     = new AuthQueriesCommands();

            Account account = AuthCQ.GetAccountByEmail(email);

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

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