From 11f9714b65e60aa4d1a5c37c8c31bea7acc7cf42 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 22 Feb 2017 22:58:02 +0100 Subject: [PATCH] signing estimate --- Yavsc/Interfaces/Workflow/IEvent.cs | 35 ++++++++------- Yavsc/Models/Billing/CommandLine.cs | 2 + Yavsc/Models/Billing/Estimate.cs | 7 +-- Yavsc/Models/Messaging/BookQueryEvent.cs | 10 +++-- Yavsc/Models/Messaging/EstimationEvent.cs | 44 +++++++++---------- .../Yavsc.Resources.YavscLocalisation.resx | 5 +-- Yavsc/Views/Estimate/Index.cshtml | 14 ++++-- .../Shared/DisplayTemplates/Estimate.cshtml | 6 ++- 8 files changed, 69 insertions(+), 54 deletions(-) diff --git a/Yavsc/Interfaces/Workflow/IEvent.cs b/Yavsc/Interfaces/Workflow/IEvent.cs index df7a8714..460df0b5 100644 --- a/Yavsc/Interfaces/Workflow/IEvent.cs +++ b/Yavsc/Interfaces/Workflow/IEvent.cs @@ -1,19 +1,22 @@ +namespace Yavsc.Interfaces.Workflow { + public interface IEvent { + /// + /// /topic/(bookquery|estimate) + /// + /// + string Topic { get; set ; } + /// + /// Should be the user's name + /// + /// + string Sender { get; set ; } + /// + /// The message + /// + /// + string Message { get; set; } + } + -public interface IEvent { - /// - /// /topic/(bookquery|estimate) - /// - /// - string Topic { get; set ; } - /// - /// Should be the user's name - /// - /// - string Sender { get; set ; } - /// - /// The message - /// - /// - string Message { get; set; } } \ No newline at end of file diff --git a/Yavsc/Models/Billing/CommandLine.cs b/Yavsc/Models/Billing/CommandLine.cs index 75f3b381..cd55e5ce 100644 --- a/Yavsc/Models/Billing/CommandLine.cs +++ b/Yavsc/Models/Billing/CommandLine.cs @@ -16,6 +16,8 @@ namespace Yavsc.Models.Billing public string Description { get; set; } public BaseProduct Article { get; set; } public int Count { get; set; } + + [DisplayFormat(DataFormatString="{0:C}")] public decimal UnitaryCost { get; set; } public long EstimateId { get; set; } diff --git a/Yavsc/Models/Billing/Estimate.cs b/Yavsc/Models/Billing/Estimate.cs index 64031b75..01e5d906 100644 --- a/Yavsc/Models/Billing/Estimate.cs +++ b/Yavsc/Models/Billing/Estimate.cs @@ -9,6 +9,7 @@ namespace Yavsc.Models.Billing { using Interfaces; using Models.Workflow; + using Newtonsoft.Json; public partial class Estimate : IEstimate { @@ -22,7 +23,7 @@ namespace Yavsc.Models.Billing /// it will result in a new estimate template /// /// - [ForeignKey("CommandId")] + [ForeignKey("CommandId"),JsonIgnore] public BookQuery Query { get; set; } public string Description { get; set; } public string Title { get; set; } @@ -62,12 +63,12 @@ namespace Yavsc.Models.Billing [Required] public string OwnerId { get; set; } - [ForeignKey("OwnerId")] + [ForeignKey("OwnerId"),JsonIgnore] public virtual PerformerProfile Owner { get; set; } [Required] public string ClientId { get; set; } - [ForeignKey("ClientId")] + [ForeignKey("ClientId"),JsonIgnore] public virtual ApplicationUser Client { get; set; } public string CommandType diff --git a/Yavsc/Models/Messaging/BookQueryEvent.cs b/Yavsc/Models/Messaging/BookQueryEvent.cs index d7544aa3..2e4a4bb5 100644 --- a/Yavsc/Models/Messaging/BookQueryEvent.cs +++ b/Yavsc/Models/Messaging/BookQueryEvent.cs @@ -1,7 +1,3 @@ - -namespace Yavsc.Models.Messaging -{ - // // BookQueryEvent.cs // @@ -23,6 +19,12 @@ namespace Yavsc.Models.Messaging // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . +namespace Yavsc.Models.Messaging +{ +using Interfaces.Workflow; + + + public class BookQueryEvent: BookQueryProviderInfo, IEvent { public BookQueryEvent() diff --git a/Yavsc/Models/Messaging/EstimationEvent.cs b/Yavsc/Models/Messaging/EstimationEvent.cs index 31c24c15..66133e8c 100644 --- a/Yavsc/Models/Messaging/EstimationEvent.cs +++ b/Yavsc/Models/Messaging/EstimationEvent.cs @@ -1,16 +1,23 @@ using System.Linq; +using Microsoft.Data.Entity; using Microsoft.Extensions.Localization; -using Yavsc.Helpers; -using Yavsc.Models.Billing; namespace Yavsc.Models.Messaging { + using Interfaces.Workflow; + using Billing; + using Yavsc.Helpers; + using System; + public class EstimationEvent: IEvent { public EstimationEvent(ApplicationDbContext context, Estimate estimate, IStringLocalizer SR) { + Topic = "Estimation"; Estimation = estimate; - var perfer = context.Performers.FirstOrDefault( + var perfer = context.Performers.Include( + p=>p.Performer + ).FirstOrDefault( p => p.PerformerId == estimate.OwnerId ); // Use estimate.OwnerId; @@ -27,28 +34,19 @@ namespace Yavsc.Models.Messaging ProviderClientInfo ProviderInfo { get; set; } Estimate Estimation { get; set; } - private string subtopic = null; - string IEvent.Topic - { - get - { - return "/topic/estimate"+subtopic!=null?"/"+subtopic:""; - } - - set - { - subtopic = value; - } - } - - string IEvent.Sender - { - get; set; - } - - string IEvent.Message + public string Topic { get; set; } + + public string Sender + { + get; set; + } + + public string Message + { + get; set; + } } } \ No newline at end of file diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.resx index 4ea89a52..0a7b4e3c 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.resx @@ -212,14 +212,13 @@ Demandes de Devis en souffrance Devis à valider Devis à accèpter ou refuser + {0} à validé et évalué votre demande, avec un devis à {1:C} + Date de l'évennement Factures à produire Factures à honnorer Paiements effectués - - {0} a validé un devis pour vous : {1}\nAu total : {2} € - Il attend maintenant votre signature. Demande de devis Date de l'évennement Page web de l'événement diff --git a/Yavsc/Views/Estimate/Index.cshtml b/Yavsc/Views/Estimate/Index.cshtml index 85fdf739..6decbb57 100644 --- a/Yavsc/Views/Estimate/Index.cshtml +++ b/Yavsc/Views/Estimate/Index.cshtml @@ -12,10 +12,10 @@ + @@ -32,10 +35,10 @@ @foreach (var item in Model) { + diff --git a/Yavsc/Views/Shared/DisplayTemplates/Estimate.cshtml b/Yavsc/Views/Shared/DisplayTemplates/Estimate.cshtml index 3dd0133d..7ef58e0c 100644 --- a/Yavsc/Views/Shared/DisplayTemplates/Estimate.cshtml +++ b/Yavsc/Views/Shared/DisplayTemplates/Estimate.cshtml @@ -1,4 +1,5 @@ @model Estimate +
@Html.DisplayNameFor(model => model.Title) @@ -23,5 +24,8 @@ }
- + + @await Component.InvokeAsync("Estimate",Model.Id)
- @Html.DisplayNameFor(model => model.Description) + @Html.DisplayNameFor(model => model.Title) - @Html.DisplayNameFor(model => model.Title) + @Html.DisplayNameFor(model => model.Description) @Html.DisplayNameFor(model => model.Query.Client) @@ -23,6 +23,9 @@ @SR["Performer"] + @Html.DisplayNameFor(model => model.ProviderValidationDate) + @SR["Id"]
- @Html.DisplayFor(modelItem => item.Description) + @Html.DisplayFor(modelItem => item.Title) - @Html.DisplayFor(modelItem => item.Title) + @Html.DisplayFor(modelItem => item.Description) @Html.DisplayFor(modelItem => item.Query.Client.UserName) @@ -43,6 +46,9 @@ @Html.DisplayFor(modelItem => item.Query.PerformerProfile.Performer.UserName) + @Html.DisplayFor(modelItem => item.ProviderValidationDate) + @Html.DisplayFor(modelItem => item.Id)