Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Changes in the download entity, add new fields

support0ff521be02d6
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs
index 48bb64b28..37c41b148 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs
@@ -2453,7 +2453,7 @@ namespace Grand.Business.System.Services.Installation
DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_cyberpunk_1.zip"),
Extension = ".zip",
Filename = "Cyberpunk",
- IsNew = true,
+ DownloadType = DownloadType.Product
};
await downloadService.InsertDownload(downloadCyberpunk1);
var downloadCyberpunk2 = new Download
@@ -2463,7 +2463,7 @@ namespace Grand.Business.System.Services.Installation
DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_cyberpunk_2.txt"),
Extension = ".txt",
Filename = "Cyberpunk",
- IsNew = true,
+ DownloadType = DownloadType.Product
};
await downloadService.InsertDownload(downloadCyberpunk2);
var productCyberpunk = new Product
@@ -2520,7 +2520,7 @@ namespace Grand.Business.System.Services.Installation
DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_GTA_1.zip"),
Extension = ".zip",
Filename = "GTA",
- IsNew = true,
+ DownloadType = DownloadType.Product
};
await downloadService.InsertDownload(downloadGTA1);
var downloadGTA2 = new Download
@@ -2530,7 +2530,7 @@ namespace Grand.Business.System.Services.Installation
DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_GTA_2.txt"),
Extension = ".txt",
Filename = "GTA",
- IsNew = true,
+ DownloadType = DownloadType.Product
};
await downloadService.InsertDownload(downloadGTA2);
var productGTA = new Product
@@ -2589,7 +2589,7 @@ namespace Grand.Business.System.Services.Installation
DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_cod_1.zip"),
Extension = ".zip",
Filename = "Call of Duty",
- IsNew = true,
+ DownloadType = DownloadType.Product
};
await downloadService.InsertDownload(downloadCod);
var productCod = new Product
diff --git a/src/Core/Grand.Domain/Media/Download.cs b/src/Core/Grand.Domain/Media/Download.cs
index 25aa57782..939161115 100644
--- a/src/Core/Grand.Domain/Media/Download.cs
+++ b/src/Core/Grand.Domain/Media/Download.cs
@@ -51,9 +51,14 @@ namespace Grand.Domain.Media
public string Extension { get; set; }
/// <summary>
- /// Gets or sets a value indicating whether the download is new
+ /// Gets or sets an download type
/// </summary>
- public bool IsNew { get; set; }
+ public DownloadType DownloadType { get; set; }
+
+ /// <summary>
+ /// Gets or sets an object reference identifier
+ /// </summary>
+ public string ReferenceId { get; set; }
}
}
diff --git a/src/Core/Grand.Domain/Media/DownloadType.cs b/src/Core/Grand.Domain/Media/DownloadType.cs
new file mode 100644
index 000000000..abdb4c368
--- /dev/null
+++ b/src/Core/Grand.Domain/Media/DownloadType.cs
@@ -0,0 +1,57 @@
+namespace Grand.Domain.Media;
+
+public enum DownloadType
+{
+ /// <summary>
+ /// None
+ /// </summary>
+ None = 0,
+ /// <summary>
+ /// Product
+ /// </summary>
+ Product = 10,
+ /// <summary>
+ /// Customer
+ /// </summary>
+ Customer = 20,
+ /// <summary>
+ /// Order
+ /// </summary>
+ Order = 30,
+ /// <summary>
+ /// Shipment
+ /// </summary>
+ Shipment = 40,
+ /// <summary>
+ /// Shipment
+ /// </summary>
+ MerchandiseReturn = 50,
+ /// <summary>
+ /// Document
+ /// </summary>
+ Document = 60,
+ /// <summary>
+ /// Course
+ /// </summary>
+ Course = 70,
+ /// <summary>
+ /// Product attribute
+ /// </summary>
+ ProductAttribute = 80,
+ /// <summary>
+ /// Checkout attribute
+ /// </summary>
+ CheckoutAttribute = 81,
+ /// <summary>
+ /// Contact attribute
+ /// </summary>
+ ContactAttribute = 82,
+ /// <summary>
+ /// Message template
+ /// </summary>
+ MessageTemplate = 90,
+ /// <summary>
+ /// Queued email
+ /// </summary>
+ QueuedEmail = 91
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Course/Partials/Lesson.TabInfo.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Course/Partials/Lesson.TabInfo.cshtml
index f02830c98..40ffdfb7d 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Course/Partials/Lesson.TabInfo.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Course/Partials/Lesson.TabInfo.cshtml
@@ -1,4 +1,8 @@
@model CourseLessonModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.Course;
+ ViewData["ReferenceId"] = Model.Id;
+}
<vc:admin-widget widget-zone="course_details_lesson_info_top" additional-data="Model" />
<div class="form-horizontal">
<div class="form-body">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Customer/Partials/CreateOrUpdate.TabNotes.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Customer/Partials/CreateOrUpdate.TabNotes.cshtml
index 3714c5f35..d57d57937 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Customer/Partials/CreateOrUpdate.TabNotes.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Customer/Partials/CreateOrUpdate.TabNotes.cshtml
@@ -1,4 +1,8 @@
@model CustomerModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.Customer;
+ ViewData["ReferenceId"] = Model.Id;
+}
<div class="panel panel-default">
<div class="panel-body">
<vc:admin-widget widget-zone="customer_details_notes_top" additional-data="Model" />
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Document/Partials/CreateOrUpdateDocument.TabInfo.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Document/Partials/CreateOrUpdateDocument.TabInfo.cshtml
index 533cd0c6e..3e7321647 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Document/Partials/CreateOrUpdateDocument.TabInfo.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Document/Partials/CreateOrUpdateDocument.TabInfo.cshtml
@@ -1,4 +1,8 @@
@model DocumentModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.Document;
+ ViewData["ReferenceId"] = Model.Id;
+}
<vc:admin-widget widget-zone="document_details_info_top" additional-data="Model" />
<div class="form-horizontal">
<div class="form-body">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/MerchandiseReturn/Partials/MerchandiseReturnNotes.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/MerchandiseReturn/Partials/MerchandiseReturnNotes.cshtml
index 75af1228e..7685c32bd 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/MerchandiseReturn/Partials/MerchandiseReturnNotes.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/MerchandiseReturn/Partials/MerchandiseReturnNotes.cshtml
@@ -1,4 +1,9 @@
@model MerchandiseReturnModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.MerchandiseReturn;
+ ViewData["ReferenceId"] = Model.Id;
+}
+
<div class="panel panel-default">
<vc:admin-widget widget-zone="merchandisereturn_details_notes_top" additional-data="Model" />
<div class="panel-body">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/MessageTemplate/Partials/CreateOrUpdate.TabInfo.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/MessageTemplate/Partials/CreateOrUpdate.TabInfo.cshtml
index 11c69f371..88f068d50 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/MessageTemplate/Partials/CreateOrUpdate.TabInfo.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/MessageTemplate/Partials/CreateOrUpdate.TabInfo.cshtml
@@ -1,6 +1,9 @@
@model MessageTemplateModel
@using Microsoft.AspNetCore.Mvc.Razor;
-
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.MessageTemplate;
+ ViewData["ReferenceId"] = Model.Id;
+}
<link rel="stylesheet" type="text/css" asp-src="@(Common.WwwRoot)/administration/codemirror/codemirror.css" />
<script asp-location="Head" asp-src="@(Common.WwwRoot)/administration/codemirror/codemirror.js"></script>
<script asp-location="Head" asp-src="@(Common.WwwRoot)/administration/codemirror/mode/xml/xml.js"></script>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Order/Partials/OrderDetails.Notes.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Order/Partials/OrderDetails.Notes.cshtml
index 828c62249..1eaca27e1 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Order/Partials/OrderDetails.Notes.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Order/Partials/OrderDetails.Notes.cshtml
@@ -1,4 +1,8 @@
@model OrderModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.Order;
+ ViewData["ReferenceId"] = Model.Id;
+}
<div class="panel panel-default">
<vc:admin-widget widget-zone="order_details_notes_top" additional-data="Model" />
<div class="panel-body">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Additional.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Additional.cshtml
index ddea1227d..d130cb995 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Additional.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Additional.cshtml
@@ -1,33 +1,36 @@
-@using Grand.Domain.Catalog;
-@model ProductModel
-<vc:admin-widget widget-zone="product_details_additional_top" additional-data="Model" />
+@model ProductModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.Product;
+ ViewData["ReferenceId"] = Model.Id;
+}
+<vc:admin-widget widget-zone="product_details_additional_top" additional-data="Model"/>
<div class="form-horizontal" id="group-order">
<div class="form-body">
<div class="form-group">
- <admin-label asp-for="DisplayOrderCategory" />
+ <admin-label asp-for="DisplayOrderCategory"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="DisplayOrderCategory" />
+ <admin-input asp-for="DisplayOrderCategory"/>
<span asp-validation-for="DisplayOrderCategory"></span>
</div>
</div>
<div class="form-group">
- <admin-label asp-for="DisplayOrderBrand" />
+ <admin-label asp-for="DisplayOrderBrand"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="DisplayOrderBrand" />
+ <admin-input asp-for="DisplayOrderBrand"/>
<span asp-validation-for="DisplayOrderBrand"></span>
</div>
</div>
<div class="form-group">
- <admin-label asp-for="DisplayOrderCollection" />
+ <admin-label asp-for="DisplayOrderCollection"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="DisplayOrderCollection" />
+ <admin-input asp-for="DisplayOrderCollection"/>
<span asp-validation-for="DisplayOrderCollection"></span>
</div>
</div>
<div class="form-group">
- <admin-label asp-for="OnSale" />
+ <admin-label asp-for="OnSale"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="OnSale" />
+ <admin-input asp-for="OnSale"/>
<span asp-validation-for="OnSale"></span>
</div>
</div>
@@ -37,26 +40,26 @@
<div class="form-horizontal" id="group-giftvoucher">
<div class="form-body">
<div class="form-group">
- <admin-label asp-for="IsGiftVoucher" />
+ <admin-label asp-for="IsGiftVoucher"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="IsGiftVoucher" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="IsGiftVoucher"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="IsGiftVoucher"></span>
</div>
</div>
<div class="form-group" id="pnlGiftVoucherType">
- <admin-label asp-for="GiftVoucherTypeId" />
+ <admin-label asp-for="GiftVoucherTypeId"/>
<div class="col-md-9 col-sm-9">
- <admin-select asp-for="GiftVoucherTypeId" asp-items="((GiftVoucherType)Model.GiftVoucherTypeId).ToSelectList(Context)" />
+ <admin-select asp-for="GiftVoucherTypeId" asp-items="((GiftVoucherType)Model.GiftVoucherTypeId).ToSelectList(Context)"/>
<span asp-validation-for="GiftVoucherTypeId"></span>
</div>
</div>
<div class="form-group" id="pnlOverriddenGiftVoucherAmount">
- <admin-label asp-for="OverGiftAmount" />
+ <admin-label asp-for="OverGiftAmount"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="OverGiftAmount" />
+ <admin-input asp-for="OverGiftAmount"/>
<span asp-validation-for="OverGiftAmount"></span>
</div>
</div>
@@ -66,84 +69,84 @@
<div class="form-horizontal" id="group-downloads">
<div class="form-body">
<div class="form-group">
- <admin-label asp-for="IsDownload" />
+ <admin-label asp-for="IsDownload"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="IsDownload" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="IsDownload"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="IsDownload"></span>
</div>
</div>
<div class="form-group" id="pnlDownloadFile">
- <admin-label asp-for="DownloadId" />
+ <admin-label asp-for="DownloadId"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="DownloadId" />
+ <admin-input asp-for="DownloadId"/>
<span asp-validation-for="DownloadId"></span>
</div>
</div>
<div class="form-group" id="pnlUnlimitedDownloads">
- <admin-label asp-for="UnlimitedDownloads" />
+ <admin-label asp-for="UnlimitedDownloads"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="UnlimitedDownloads" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="UnlimitedDownloads"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="UnlimitedDownloads"></span>
</div>
</div>
<div class="form-group" id="pnlMaxNumberOfDownloads">
- <admin-label asp-for="MaxNumberOfDownloads" />
+ <admin-label asp-for="MaxNumberOfDownloads"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="MaxNumberOfDownloads" />
+ <admin-input asp-for="MaxNumberOfDownloads"/>
<span asp-validation-for="MaxNumberOfDownloads"></span>
</div>
</div>
<div class="form-group" id="pnlDownloadExpirationDays">
- <admin-label asp-for="DownloadExpirationDays" />
+ <admin-label asp-for="DownloadExpirationDays"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="DownloadExpirationDays" />
+ <admin-input asp-for="DownloadExpirationDays"/>
<span asp-validation-for="DownloadExpirationDays"></span>
</div>
</div>
<div class="form-group" id="pnlDownloadActivationType">
- <admin-label asp-for="DownloadActivationTypeId" />
+ <admin-label asp-for="DownloadActivationTypeId"/>
<div class="col-md-9 col-sm-9">
- <admin-select asp-for="DownloadActivationTypeId" asp-items="((DownloadActivationType)Model.DownloadActivationTypeId).ToSelectList(Context)" />
+ <admin-select asp-for="DownloadActivationTypeId" asp-items="((DownloadActivationType)Model.DownloadActivationTypeId).ToSelectList(Context)"/>
<span asp-validation-for="DownloadActivationTypeId"></span>
</div>
</div>
<div class="form-group" id="pnlHasUserAgreement">
- <admin-label asp-for="HasUserAgreement" />
+ <admin-label asp-for="HasUserAgreement"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="HasUserAgreement" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="HasUserAgreement"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="HasUserAgreement"></span>
</div>
</div>
<div class="form-group" id="pnlUserAgreementText">
- <admin-label asp-for="UserAgreementText" />
+ <admin-label asp-for="UserAgreementText"/>
<div class="col-md-9 col-sm-9">
<admin-textarea asp-for="UserAgreementText"></admin-textarea>
<span asp-validation-for="UserAgreementText"></span>
</div>
</div>
<div class="form-group" id="pnlHasSampleDownload">
- <admin-label asp-for="HasSampleDownload" />
+ <admin-label asp-for="HasSampleDownload"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="HasSampleDownload" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="HasSampleDownload"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="HasSampleDownload"></span>
</div>
</div>
<div class="form-group" id="pnlSampleDownloadFile">
- <admin-label asp-for="SampleDownloadId" />
+ <admin-label asp-for="SampleDownloadId"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="SampleDownloadId" />
+ <admin-input asp-for="SampleDownloadId"/>
<span asp-validation-for="SampleDownloadId"></span>
</div>
</div>
@@ -152,33 +155,33 @@
<div class="form-horizontal" id="group-recurring">
<div class="form-body">
<div class="form-group">
- <admin-label asp-for="IsRecurring" />
+ <admin-label asp-for="IsRecurring"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="IsRecurring" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="IsRecurring"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="IsRecurring"></span>
</div>
</div>
<div class="form-group" id="pnlCycleLength">
- <admin-label asp-for="RecurringCycleLength" />
+ <admin-label asp-for="RecurringCycleLength"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="RecurringCycleLength" />
+ <admin-input asp-for="RecurringCycleLength"/>
<span asp-validation-for="RecurringCycleLength"></span>
</div>
</div>
<div class="form-group" id="pnlCyclePeriod">
- <admin-label asp-for="RecurringCyclePeriodId" />
+ <admin-label asp-for="RecurringCyclePeriodId"/>
<div class="col-md-9 col-sm-9">
- <admin-select asp-for="RecurringCyclePeriodId" asp-items="((RecurringCyclePeriod)Model.RecurringCyclePeriodId).ToSelectList(Context)" />
+ <admin-select asp-for="RecurringCyclePeriodId" asp-items="((RecurringCyclePeriod)Model.RecurringCyclePeriodId).ToSelectList(Context)"/>
<span asp-validation-for="RecurringCyclePeriodId"></span>
</div>
</div>
<div class="form-group" id="pnlTotalCycles">
- <admin-label asp-for="RecurringTotalCycles" />
+ <admin-label asp-for="RecurringTotalCycles"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="RecurringTotalCycles" />
+ <admin-input asp-for="RecurringTotalCycles"/>
<span asp-validation-for="RecurringTotalCycles"></span>
</div>
</div>
@@ -188,27 +191,27 @@
<div class="form-horizontal" id="group-required-other-products">
<div class="form-body">
<div class="form-group">
- <admin-label asp-for="RequireOtherProducts" />
+ <admin-label asp-for="RequireOtherProducts"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="RequireOtherProducts" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="RequireOtherProducts"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="RequireOtherProducts"></span>
</div>
</div>
<div class="form-group" id="pnlRequiredProductIds">
- <admin-label asp-for="RequiredProductIds" />
+ <admin-label asp-for="RequiredProductIds"/>
<div class="col-md-9 col-sm-9">
- <admin-input asp-for="RequiredProductIds" />
+ <admin-input asp-for="RequiredProductIds"/>
<span asp-validation-for="RequiredProductIds"></span>
<span id="required-products-check-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>
<a id="btnAddNewRequiredProduct"
- href="@(Url.Action("RequiredProductAddPopup", "Product", new { btnId = "btnRefreshRequiredProducts", productIdsInput = "RequiredProductIds", area = Constants.AreaAdmin }))"
- class="k-button">
+ href="@(Url.Action("RequiredProductAddPopup", "Product", new { btnId = "btnRefreshRequiredProducts", productIdsInput = "RequiredProductIds", area = Constants.AreaAdmin }))"
+ class="k-button">
@Loc["Admin.Catalog.Products.Fields.RequiredProductIds.AddNew"]
</a>
- <input type="submit" id="btnRefreshRequiredProducts" style="display: none" />
+ <input type="submit" id="btnRefreshRequiredProducts" style="display: none"/>
<script>
$(document).ready(function () {
$('#btnAddNewRequiredProduct').magnificPopup({
@@ -234,15 +237,15 @@
</div>
</div>
<div class="form-group" id="pnlAutomaticallyAddRequiredProducts">
- <admin-label asp-for="AutoAddRequiredProducts" />
+ <admin-label asp-for="AutoAddRequiredProducts"/>
<div class="col-md-9 col-sm-9">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
- <admin-input asp-for="AutoAddRequiredProducts" />
- <div class="control__indicator"></div>
+ <admin-input asp-for="AutoAddRequiredProducts"/>
+ <div class="control__indicator"></div>
</label>
<span asp-validation-for="AutoAddRequiredProducts"></span>
</div>
</div>
</div>
</div>
-<vc:admin-widget widget-zone="product_details_additional_bottom" additional-data="Model" />
\ No newline at end of file
+<vc:admin-widget widget-zone="product_details_additional_bottom" additional-data="Model"/>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/QueuedEmail/Partials/CreateOrUpdate.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/QueuedEmail/Partials/CreateOrUpdate.cshtml
index 83f368ed7..d3efe1b39 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/QueuedEmail/Partials/CreateOrUpdate.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/QueuedEmail/Partials/CreateOrUpdate.cshtml
@@ -1,4 +1,8 @@
@model QueuedEmailModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.QueuedEmail;
+ ViewData["ReferenceId"] = Model.Id;
+}
<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />
<div class="form-horizontal">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Download.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Download.cshtml
index d7b27948e..d37ad560d 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Download.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/EditorTemplates/Download.cshtml
@@ -25,7 +25,7 @@
cache: false,
type: "POST",
url: "@(Url.Action("SaveDownloadUrl", "Download", new { area = Constants.AreaAdmin }))",
- data: { "downloadUrl": downloadUrl },
+ data: { "downloadUrl": downloadUrl, DownloadType: '@ViewData["DownloadType"]', ReferenceId: '@ViewData["ReferenceId"]' },
success: function (data) {
if (data.success) {
$('#pnlDownloadURLResult@(randomNumber)').fadeIn("slow").delay(1000).fadeOut("slow");
@@ -138,7 +138,11 @@
$(document).ready(function () {
$("#@clientId").fineUploader({
request: {
- endpoint: '@(Url.Action("AsyncUpload", "Download", new { area = Constants.AreaAdmin }))'
+ endpoint: '@(Url.Action("AsyncUpload", "Download", new { area = Constants.AreaAdmin }))',
+ params: {
+ DownloadType: '@ViewData["DownloadType"]',
+ ReferenceId: '@ViewData["ReferenceId"]'
+ }
},
template: "@(clientId)-qq-template",
multiple: false
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipment/Partials/ShipmentNotes.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipment/Partials/ShipmentNotes.cshtml
index ada689f4d..0559f48c6 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipment/Partials/ShipmentNotes.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipment/Partials/ShipmentNotes.cshtml
@@ -1,4 +1,8 @@
@model ShipmentModel
+@{
+ ViewData["DownloadType"] = Grand.Domain.Media.DownloadType.Shipment;
+ ViewData["ReferenceId"] = Model.Id;
+}
<div class="panel panel-default">
<vc:admin-widget widget-zone="order_shipment_details_notes_top" additional-data="Model" />
<div class="panel-body">
diff --git a/src/Web/Grand.Web.Admin/Controllers/DownloadController.cs b/src/Web/Grand.Web.Admin/Controllers/DownloadController.cs
index 4f18e0c94..7f25ad074 100644
--- a/src/Web/Grand.Web.Admin/Controllers/DownloadController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/DownloadController.cs
@@ -2,6 +2,7 @@
using Grand.Business.Core.Interfaces.Storage;
using Grand.Web.Common.Security.Authorization;
using Grand.Domain.Media;
+using Grand.Infrastructure;
using Grand.Web.Admin.Extensions;
using Microsoft.AspNetCore.Mvc;
using Grand.Web.Common.Extensions;
@@ -12,10 +13,11 @@ namespace Grand.Web.Admin.Controllers
public partial class DownloadController : BaseAdminController
{
private readonly IDownloadService _downloadService;
-
- public DownloadController(IDownloadService downloadService)
+ private readonly IWorkContext _workContext;
+ public DownloadController(IDownloadService downloadService, IWorkContext workContext)
{
_downloadService = downloadService;
+ _workContext = workContext;
}
public async Task<IActionResult> DownloadFile(Guid downloadGuid)
@@ -44,7 +46,7 @@ namespace Grand.Web.Admin.Controllers
//do not validate request token (XSRF)
[IgnoreAntiforgeryToken]
- public async Task<IActionResult> SaveDownloadUrl(string downloadUrl)
+ public async Task<IActionResult> SaveDownloadUrl(string downloadUrl, DownloadType downloadType = DownloadType.None, string referenceId = "")
{
if (string.IsNullOrEmpty(downloadUrl))
{
@@ -55,7 +57,8 @@ namespace Grand.Web.Admin.Controllers
DownloadGuid = Guid.NewGuid(),
UseDownloadUrl = true,
DownloadUrl = downloadUrl,
- IsNew = true
+ DownloadType = downloadType,
+ ReferenceId = referenceId
};
await _downloadService.InsertDownload(download);
@@ -66,7 +69,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
//do not validate request token (XSRF)
[IgnoreAntiforgeryToken]
- public virtual async Task<IActionResult> AsyncUpload()
+ public virtual async Task<IActionResult> AsyncUpload(DownloadType downloadType = DownloadType.None, string referenceId = "")
{
var form = await HttpContext.Request.ReadFormAsync();
var httpPostedFile = form.Files.FirstOrDefault();
@@ -84,28 +87,29 @@ namespace Grand.Web.Admin.Controllers
var qqFileNameParameter = "qqfilename";
var fileName = httpPostedFile.FileName;
- if (String.IsNullOrEmpty(fileName) && form.ContainsKey(qqFileNameParameter))
+ if (string.IsNullOrEmpty(fileName) && form.ContainsKey(qqFileNameParameter))
fileName = form[qqFileNameParameter].ToString();
- //remove path (passed in IE)
+
fileName = Path.GetFileName(fileName);
var contentType = httpPostedFile.ContentType;
var fileExtension = Path.GetExtension(fileName);
- if (!String.IsNullOrEmpty(fileExtension))
+ if (!string.IsNullOrEmpty(fileExtension))
fileExtension = fileExtension.ToLowerInvariant();
var download = new Download {
DownloadGuid = Guid.NewGuid(),
+ CustomerId = _workContext.CurrentCustomer.Id,
UseDownloadUrl = false,
DownloadUrl = "",
DownloadBinary = fileBinary,
ContentType = contentType,
- //we store filename without extension for downloads
Filename = Path.GetFileNameWithoutExtension(fileName),
Extension = fileExtension,
- IsNew = true
+ DownloadType = downloadType,
+ ReferenceId = referenceId
};
await _downloadService.InsertDownload(download);
diff --git a/src/Web/Grand.Web/Controllers/ContactController.cs b/src/Web/Grand.Web/Controllers/ContactController.cs
index 442235769..5b05c1502 100644
--- a/src/Web/Grand.Web/Controllers/ContactController.cs
+++ b/src/Web/Grand.Web/Controllers/ContactController.cs
@@ -197,7 +197,8 @@ public class ContactController : BasePublicController
ContentType = contentType,
Filename = Path.GetFileNameWithoutExtension(fileName),
Extension = fileExtension,
- IsNew = true
+ DownloadType = DownloadType.ContactAttribute,
+ ReferenceId = attributeId
};
await downloadService.InsertDownload(download);
diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.cs
index 41821359c..56e829e8b 100644
--- a/src/Web/Grand.Web/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web/Controllers/ProductController.cs
@@ -279,7 +279,8 @@ namespace Grand.Web.Controllers
ContentType = contentType,
Filename = Path.GetFileNameWithoutExtension(fileName),
Extension = fileExtension,
- IsNew = true
+ DownloadType = DownloadType.ProductAttribute,
+ ReferenceId = attributeId
};
await downloadService.InsertDownload(download);
diff --git a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs b/src/Web/Grand.Web/Controllers/ShoppingCartController.cs
index ac9d1b0af..4ffa23611 100644
--- a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs
+++ b/src/Web/Grand.Web/Controllers/ShoppingCartController.cs
@@ -245,7 +245,8 @@ namespace Grand.Web.Controllers
ContentType = contentType,
Filename = Path.GetFileNameWithoutExtension(fileName),
Extension = fileExtension,
- IsNew = true
+ DownloadType = DownloadType.CheckoutAttribute,
+ ReferenceId = attributeId
};
await downloadService.InsertDownload(download);