roadie/Roadie.Api.Library/FileOperationResult.cs

53 lines
1.5 KiB
C#
Raw Normal View History

using System;
2018-11-11 01:11:58 +00:00
using System.Collections.Generic;
using System.Linq;
using Microsoft.Net.Http.Headers;
2018-11-11 01:11:58 +00:00
namespace Roadie.Library
{
/// <summary>
2019-07-03 16:21:29 +00:00
/// A OperationResult specific to a File type request.
2018-11-11 01:11:58 +00:00
/// </summary>
public class FileOperationResult<T> : OperationResult<T>
{
2019-07-03 16:21:29 +00:00
public string ContentType { get; set; }
2018-11-11 01:11:58 +00:00
public EntityTagHeaderValue ETag { get; set; }
2019-07-03 16:21:29 +00:00
2018-11-11 01:11:58 +00:00
public DateTimeOffset? LastModified { get; set; }
2018-11-11 14:46:09 +00:00
public FileOperationResult()
{
}
2018-11-11 01:11:58 +00:00
public FileOperationResult(string message)
{
2019-07-03 16:21:29 +00:00
AddMessage(message);
2018-11-11 01:11:58 +00:00
}
2018-11-11 16:20:33 +00:00
public FileOperationResult(bool isNotFoundResult, string message)
{
2019-07-03 16:21:29 +00:00
IsNotFoundResult = isNotFoundResult;
AddMessage(message);
2018-11-11 16:20:33 +00:00
}
2018-11-11 01:11:58 +00:00
public FileOperationResult(IEnumerable<string> messages = null)
{
if (messages != null && messages.Any())
{
2019-07-03 16:21:29 +00:00
AdditionalData = new Dictionary<string, object>();
messages.ToList().ForEach(x => AddMessage(x));
2018-11-11 01:11:58 +00:00
}
}
2018-11-11 16:20:33 +00:00
public FileOperationResult(bool isNotFoundResult, IEnumerable<string> messages = null)
{
2019-07-03 16:21:29 +00:00
IsNotFoundResult = isNotFoundResult;
2018-11-11 20:45:44 +00:00
if (messages != null && messages.Any())
{
2019-07-03 16:21:29 +00:00
AdditionalData = new Dictionary<string, object>();
messages.ToList().ForEach(x => AddMessage(x));
2018-11-11 20:45:44 +00:00
}
2018-11-11 16:20:33 +00:00
}
2018-11-11 01:11:58 +00:00
}
}