Adds file names at download from MVC web API
This commit is contained in:
parent
f35e82d354
commit
71f0d756b3
1 changed files with 13 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ using System.Collections.Specialized;
|
||||||
using Yavsc.Model;
|
using Yavsc.Model;
|
||||||
using Yavsc.Model.FrontOffice;
|
using Yavsc.Model.FrontOffice;
|
||||||
using Yavsc.Helpers;
|
using Yavsc.Helpers;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace Yavsc.ApiControllers
|
namespace Yavsc.ApiControllers
|
||||||
{
|
{
|
||||||
|
|
@ -93,11 +94,15 @@ namespace Yavsc.ApiControllers
|
||||||
if (texest == null)
|
if (texest == null)
|
||||||
throw new InvalidOperationException (
|
throw new InvalidOperationException (
|
||||||
"Not an estimate");
|
"Not an estimate");
|
||||||
return new HttpResponseMessage () {
|
HttpResponseMessage result = new HttpResponseMessage () {
|
||||||
Content = new ObjectContent (typeof(string),
|
Content = new ObjectContent (typeof(string),
|
||||||
texest,
|
texest,
|
||||||
new SimpleFormatter ("text/x-tex"))
|
new SimpleFormatter ("text/x-tex"))
|
||||||
};
|
};
|
||||||
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue ("attachment") {
|
||||||
|
FileName = "estimate-" + id.ToString () + ".tex"
|
||||||
|
};
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string estimateToTex (long estimid)
|
private string estimateToTex (long estimid)
|
||||||
|
|
@ -156,11 +161,16 @@ namespace Yavsc.ApiControllers
|
||||||
LocalizedText.Estimate_not_found))
|
LocalizedText.Estimate_not_found))
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpResponseMessage () {
|
HttpResponseMessage result = new HttpResponseMessage () {
|
||||||
Content = new ObjectContent (typeof(string),
|
Content = new ObjectContent (typeof(string),
|
||||||
texest,
|
texest,
|
||||||
new TexToPdfFormatter ())
|
new TexToPdfFormatter ())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue ("attachment") {
|
||||||
|
FileName = "estimate-" + id.ToString () + ".pdf"
|
||||||
|
};
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpResponseMessage DefaultResponse()
|
private HttpResponseMessage DefaultResponse()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue