public bool IsAnyTrackOfTheEpSubmitted(ExtendedPlay epObject) { using (DatabaseContext db = new DatabaseContext()) { return(db.EpTrackMasters.Where(rec => rec.Ep_Id == epObject.Id).Any(rec => rec.StoreSubmissionStatus == 1)); } }
public int EPEmptiness(ExtendedPlay epObject) { using (DatabaseContext db = new DatabaseContext()) { var result = db.ExtendedPlays.Find(epObject.Id); if (result != null) { if (result.Submitted_Track == 0) { //EP is totally empty return(1); } else if (result.Submitted_Track > 0 && result.Submitted_Track != result.Total_Track) { //EP is partially empty return(2); } else { //EP is full return(3); } } else { //EP not found return(2); } } }
public int EditEp(Guid epId, string epName, int totalTrack) { EPQueriesCommands EpCQ = new EPQueriesCommands(); ExtendedPlay ep = EpCQ.GetEpById(epId); if (ep != null) { if (EpCQ.EPEmptiness(ep) != 1) { //Can't edit Ep as one song alredy registered under the album return(2); } ep.Ep_Name = epName; ep.Total_Track = totalTrack; var result = EpCQ.EditEpDetails(ep); if (result != 1) { //Internal Error occured while changing data for the Ep return(3); } else { //Ep details changed Successfully return(1); } } else { //No Ep found with the Id provided return(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); } }
public int DeleteEp(ExtendedPlay epObject) { if (IsAnyTrackOfTheEpSubmitted(epObject)) { //Can't delete Ep as one of the song from the album already submitted to the store. return(0); } using (DatabaseContext db = new DatabaseContext()) { try { Guid?purchaseId = epObject.PurchaseTrack_RefNo; db.Entry(epObject).State = EntityState.Deleted; db.SaveChanges(); try { var purchaseRecord = db.PurchaseRecords.Find(purchaseId); if (purchaseRecord != null) { purchaseRecord.Usage_Date = null; purchaseRecord.Usage_Exp_Date = null; db.Entry(purchaseRecord).State = EntityState.Modified; db.SaveChanges(); return(1); } else { //Error while updating the associated purchase record. User can't create an Ep with the valid purchase return(4); } } catch { return(3); } } catch (Exception ex) { string msg = ex.ToString(); //Operation Faild while deleting album. Internal error occured; return(2); } } }
public int EditEpDetails(ExtendedPlay epObject) { using (DatabaseContext db = new DatabaseContext()) { try { db.Entry(epObject).State = EntityState.Modified; db.SaveChanges(); //Ep details changed Successfully return(1); } catch { //Internal Error occured while changing data for the Ep return(0); } } }
public int CreateEP(ExtendedPlay epObject) { using (DatabaseContext db = new DatabaseContext()) { try { db.ExtendedPlays.Add(epObject); db.SaveChanges(); //Successfully created EP; return(1); } catch { //Internal error occured while creating Ep. return(0); } } }
public int EditAlbumDetailsByUser(ExtendedPlay epObject) { if (EPEmptiness(epObject) != 1) { //Can't edit Ep as one song alredy registered under the Ep return(2); } using (DatabaseContext db = new DatabaseContext()) { try { db.Entry(epObject).State = EntityState.Modified; db.SaveChanges(); //Ep details changed Successfully return(1); } catch { //Internal Error occured while changing data for the album return(0); } } }