105 lines
3.1 KiB
C#
105 lines
3.1 KiB
C#
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BookAStar.Model.Workflow
|
|
{
|
|
using Data;
|
|
using Interfaces;
|
|
using Social;
|
|
|
|
public partial class Estimate : IEstimate
|
|
{
|
|
public long Id { get; set; }
|
|
public long? CommandId { get; set; }
|
|
public string CommandType { get; set; }
|
|
// Markdown expected
|
|
public string Description { get; set; }
|
|
public string Title { get; set; }
|
|
public List<BillingLine> Bill { get; set; }
|
|
/// <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>
|
|
public List<string> AttachedGraphics { get; set; }
|
|
[JsonIgnore]
|
|
public string AttachedGraphicsString
|
|
{
|
|
get { return AttachedGraphics==null?null:string.Join(":", AttachedGraphics); }
|
|
set { AttachedGraphics = value.Split(':').ToList(); }
|
|
}
|
|
/// <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; }
|
|
[JsonIgnore]
|
|
public string AttachedFilesString
|
|
{
|
|
get { return AttachedFiles == null ? null : string.Join(":", AttachedFiles); }
|
|
set { AttachedFiles = value.Split(':').ToList(); }
|
|
}
|
|
|
|
public string OwnerId { get; set; }
|
|
[JsonIgnore]
|
|
public ClientProviderInfo Owner
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(OwnerId))
|
|
{
|
|
var dm = DataManager.Instance;
|
|
return dm.Contacts.LocalGet(OwnerId);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
public string ClientId { get; set; }
|
|
[JsonIgnore]
|
|
public BookQuery Query
|
|
{
|
|
get
|
|
{
|
|
if (CommandId.HasValue)
|
|
{
|
|
var dm = DataManager.Instance;
|
|
return dm.BookQueries.LocalGet(CommandId.Value);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
[JsonIgnore]
|
|
public ClientProviderInfo Client
|
|
{
|
|
get
|
|
{
|
|
return DataManager.Instance.Contacts.LocalGet(ClientId);
|
|
}
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public decimal Total { get
|
|
{
|
|
return Bill?.Aggregate((decimal)0, (t, l) => t + l.Count * l.UnitaryCost) ?? (decimal)0;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// This validation comes from the provider.
|
|
/// As long as it's an estimate, no client validation
|
|
/// is formaly needed
|
|
/// </summary>
|
|
public DateTime ProviderValidationDate { get; set; }
|
|
|
|
public DateTime ClientApprouvalDate { get; set; }
|
|
|
|
}
|
|
}
|