public void RecordDownloadHistory(string iPAddress)
        {
            DBDownloadTicket.AddDownloadHistory(
                Guid.NewGuid(),
                this.guid,
                DateTime.UtcNow,
                iPAddress);

            IncrementDownloadCount();
        }
 private bool Update()
 {
     return(DBDownloadTicket.Update(
                this.guid,
                this.productGuid,
                this.fullfillTermsGuid,
                this.downloadsAllowed,
                this.expireAfterDays,
                this.countAfterDownload,
                this.purchaseTime,
                this.downloadedCount));
 }
        public static DataTable GetPage(
            Guid storeGuid,
            int pageNumber,
            int pageSize)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Guid", typeof(Guid));
            dataTable.Columns.Add("StoreGuid", typeof(Guid));
            dataTable.Columns.Add("OrderGuid", typeof(Guid));
            dataTable.Columns.Add("UserGuid", typeof(Guid));
            dataTable.Columns.Add("ProductGuid", typeof(Guid));
            dataTable.Columns.Add("FullfillTermsGuid", typeof(Guid));
            dataTable.Columns.Add("DownloadsAllowed", typeof(int));
            dataTable.Columns.Add("ExpireAfterDays", typeof(int));
            dataTable.Columns.Add("CountAfterDownload", typeof(bool));
            dataTable.Columns.Add("PurchaseTime", typeof(DateTime));
            dataTable.Columns.Add("DownloadedCount", typeof(int));
            dataTable.Columns.Add("TotalPages", typeof(int));

            using (IDataReader reader = DBDownloadTicket.GetPageByStore(
                       storeGuid,
                       pageNumber,
                       pageSize))
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();
                    row["Guid"]               = reader["Guid"];
                    row["StoreGuid"]          = reader["StoreGuid"];
                    row["OrderGuid"]          = reader["OrderGuid"];
                    row["UserGuid"]           = reader["UserGuid"];
                    row["ProductGuid"]        = reader["ProductGuid"];
                    row["FullfillTermsGuid"]  = reader["FullfillTermsGuid"];
                    row["DownloadsAllowed"]   = reader["DownloadsAllowed"];
                    row["ExpireAfterDays"]    = reader["ExpireAfterDays"];
                    row["CountAfterDownload"] = reader["CountAfterDownload"];
                    row["PurchaseTime"]       = reader["PurchaseTime"];
                    row["DownloadedCount"]    = reader["DownloadedCount"];
                    row["TotalPages"]         = Convert.ToInt32(reader["TotalPages"]);
                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
 private void GetFullfillDownloadTicket(Guid guid)
 {
     using (IDataReader reader = DBDownloadTicket.Get(guid))
     {
         if (reader.Read())
         {
             this.guid               = new Guid(reader["Guid"].ToString());
             this.storeGuid          = new Guid(reader["StoreGuid"].ToString());
             this.orderGuid          = new Guid(reader["OrderGuid"].ToString());
             this.userGuid           = new Guid(reader["UserGuid"].ToString());
             this.productGuid        = new Guid(reader["ProductGuid"].ToString());
             this.fullfillTermsGuid  = new Guid(reader["FullfillTermsGuid"].ToString());
             this.downloadsAllowed   = Convert.ToInt32(reader["DownloadsAllowed"]);
             this.expireAfterDays    = Convert.ToInt32(reader["ExpireAfterDays"]);
             this.countAfterDownload = Convert.ToBoolean(reader["CountAfterDownload"]);
             this.purchaseTime       = Convert.ToDateTime(reader["PurchaseTime"]);
             this.downloadedCount    = Convert.ToInt32(reader["DownloadedCount"]);
         }
     }
 }
        private bool Create()
        {
            Guid newID = Guid.NewGuid();

            this.guid = newID;

            int rowsAffected = DBDownloadTicket.Add(
                this.guid,
                this.storeGuid,
                this.orderGuid,
                this.userGuid,
                this.productGuid,
                this.fullfillTermsGuid,
                this.downloadsAllowed,
                this.expireAfterDays,
                this.countAfterDownload,
                this.purchaseTime,
                this.downloadedCount);

            return(rowsAffected > 0);
        }
 public static bool MoveOrder(
     Guid orderGuid,
     Guid newUserGuid)
 {
     return(DBDownloadTicket.MoveOrder(orderGuid, newUserGuid));
 }
 public static IDataReader GetDownloadHistory(Guid ticketGuid)
 {
     return(DBDownloadTicket.GetDownloadHistory(ticketGuid));
 }
 public static IDataReader GetByOrder(Guid orderGuid)
 {
     return(DBDownloadTicket.GetByOrder(orderGuid));
 }
 public static bool DeleteByOrder(Guid orderGuid)
 {
     return(DBDownloadTicket.DeleteByOrder(orderGuid));
 }
 public static bool Delete(Guid guid)
 {
     return(DBDownloadTicket.Delete(guid));
 }
 private void IncrementDownloadCount()
 {
     this.downloadedCount += 1;
     DBDownloadTicket.IncrementDownloadCount(this.guid);
 }