Commit 050c74be authored by SergeevaAA's avatar SergeevaAA

Исправление методов для скачивания файлов

parent 0f8d4693
......@@ -159,11 +159,11 @@
/// <returns>Существует ли файл</returns>
[Authorize(Roles = "admin, user")]
[HttpGet]
public ActionResult IsExist(long id)
public ActionResult GetDownloadUrl(long id)
{
if (_fileService.IsExist(id))
{
return Ok();
return Ok($"{Url.Action("Download", "File")}/{id}");
}
else
{
......
......@@ -25,7 +25,7 @@
<td><input asp-for="@file.User" /></td>
<td><input asp-for="@file.Description" /></td>
<td>
<button type="submit" class="download" onclick="downloadFile(@file.Id, $(this).attr('name'))" name="@Url.Action("Download", "File", new { id = @file.Id })" title="Скачать файл" />
<button type="submit" class="download" onclick="downloadFile(@file.Id)" title="Скачать файл" />
@if (User.IsInRole("admin"))
{
......@@ -44,14 +44,12 @@
</div>
<script>
function downloadFile(id, url) {
console.log("url: " + url);
console.log("id: " + id);
$.get('@Url.Action("IsExist", "File")', { id: id })
.done(function (message) {
function downloadFile(id) {
$.get('@Url.Action("GetDownloadUrl", "File")', { id: id })
.done(function (url) {
location.href = url;
})
.fail(function (xhr, status, error) {
.fail(function (xhr) {
searchFiles();
alert(xhr.responseText);
})
......@@ -63,7 +61,7 @@
searchFiles();
alert(message);
})
.fail(function (xhr, status, error) {
.fail(function (xhr) {
searchFiles();
alert(xhr.responseText);
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment