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

78 lines
2.4 KiB
C#
Raw Normal View History

2016-09-21 04:02:40 +02:00
using BookAStar.Helpers;
2016-09-29 04:54:14 +02:00
using BookAStar.Model.Interfaces;
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 int? Status { get; set; }
public string Title { get; set; }
2016-09-29 04:54:14 +02:00
public List<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-07 18:14:28 +02:00
public List<string> AttachedGraphics { get; set; }
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>
public List<string> AttachedFiles { get; set; }
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-09-21 04:02:40 +02:00
public BookQueryData Query
{
get
{
if (CommandId.HasValue)
{
return DataManager.Current.BookQueries.LocalGet(CommandId.Value);
}
return null;
}
}
public ClientProviderInfo Client
{
get
{
return DataManager.Current.Contacts.LocalGet(ClientId);
}
}
2016-09-25 00:44:30 +02:00
2016-10-03 18:39:14 +02:00
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
}
}