yavsc/BookAStar/BookAStar/Model/Workflow/Estimate.cs

81 lines
2.5 KiB
C#
Raw Normal View History

using BookAStar.Data;
using BookAStar.Helpers;
2016-09-29 04:54:14 +02:00
using BookAStar.Model.Interfaces;
2016-10-18 15:51:56 +02:00
using Newtonsoft.Json;
2016-09-21 04:02:40 +02:00
using System.Collections.Generic;
2016-09-10 00:53:08 +02:00
using System.Linq;
namespace BookAStar.Model.Workflow
{
2016-09-29 04:54:14 +02:00
public partial class Estimate : IEstimate
2016-09-10 00:53:08 +02:00
{
public long Id { get; set; }
public long? CommandId { get; set; }
2016-09-21 04:02:40 +02:00
public string CommandType { get; set; }
// Markdown expected
2016-09-10 00:53:08 +02:00
public string Description { get; set; }
public string Title { get; set; }
2016-10-13 16:19:28 +02:00
public IList<BillingLine> Bill { get; set; }
2016-09-10 00:53:08 +02:00
/// <summary>
/// List of attached graphic files
/// to this estimate, as relative pathes to
/// the command performer's root path.
/// In db, they are separated by <c>:</c>
/// </summary>
/// <returns></returns>
2016-10-13 16:19:28 +02:00
public IList<string> AttachedGraphics { get; set; }
2016-10-18 15:51:56 +02:00
[JsonIgnore]
2016-09-10 00:53:08 +02:00
public string AttachedGraphicsString
{
2016-10-07 18:14:28 +02:00
get { return AttachedGraphics==null?null:string.Join(":", AttachedGraphics); }
set { AttachedGraphics = value.Split(':').ToList(); }
2016-09-10 00:53:08 +02:00
}
/// <summary>
/// List of attached files
/// to this estimate, as relative pathes to
/// the command performer's root path.
/// In db, they are separated by <c>:</c>
/// </summary>
/// <returns></returns>
2016-10-13 16:19:28 +02:00
public IList<string> AttachedFiles { get; set; }
2016-10-18 15:51:56 +02:00
[JsonIgnore]
2016-09-10 00:53:08 +02:00
public string AttachedFilesString
{
2016-09-21 04:02:40 +02:00
get { return AttachedFiles == null ? null : string.Join(":", AttachedFiles); }
2016-09-10 00:53:08 +02:00
set { AttachedFiles = value.Split(':').ToList(); }
}
public string OwnerId { get; set; }
public string ClientId { get; set; }
2016-10-18 15:51:56 +02:00
[JsonIgnore]
2016-09-21 04:02:40 +02:00
public BookQueryData Query
{
get
{
if (CommandId.HasValue)
{
2016-10-18 15:51:56 +02:00
var dm = DataManager.Current;
return dm.BookQueries.LocalGet(CommandId.Value);
2016-09-21 04:02:40 +02:00
}
return null;
}
}
2016-10-18 15:51:56 +02:00
[JsonIgnore]
2016-09-21 04:02:40 +02:00
public ClientProviderInfo Client
{
get
{
return DataManager.Current.Contacts.LocalGet(ClientId);
}
}
2016-09-25 00:44:30 +02:00
2016-10-18 15:51:56 +02:00
[JsonIgnore]
2016-09-25 00:44:30 +02:00
public decimal Total { get
{
return Bill?.Aggregate((decimal)0, (t, l) => t + l.Count * l.UnitaryCost) ?? (decimal)0;
}
}
2016-09-27 02:35:45 +02:00
2016-09-10 00:53:08 +02:00
}
}