bug fix #171 device batch attachments not working

This commit is contained in:
Gary Sharp
2025-03-14 16:40:55 +11:00
parent fd3eb80648
commit bccbb20b84
11 changed files with 337 additions and 136 deletions
@@ -652,7 +652,8 @@ namespace Disco.Web.Areas.API.Controllers
}
[DiscoAuthorize(Claims.Config.DeviceBatch.Configure)]
public virtual ActionResult AttachmentUpload(int id, string Comments)
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult AttachmentUpload(int id, string comments)
{
var batch = Database.DeviceBatches.Find(id);
if (batch != null)
@@ -666,14 +667,14 @@ namespace Disco.Web.Areas.API.Controllers
if (string.IsNullOrEmpty(contentType) || contentType.Equals("unknown/unknown", StringComparison.OrdinalIgnoreCase))
contentType = MimeTypes.ResolveMimeType(file.FileName);
var attachment = new Disco.Models.Repository.DeviceBatchAttachment()
var attachment = new DeviceBatchAttachment()
{
DeviceBatchId = batch.Id,
TechUserId = CurrentUser.UserId,
Filename = file.FileName,
MimeType = contentType,
Timestamp = DateTime.Now,
Comments = Comments
Comments = comments
};
Database.DeviceBatchAttachments.Add(attachment);
Database.SaveChanges();