From e2c34067a8edc5f11543e95413ca8bea367eba8d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Thu, 12 Jan 2017 10:12:28 +0100 Subject: [PATCH] Start to implement a FrontOffice index --- Yavsc/Controllers/FrontOfficeController.cs | 20 ++++++++--- .../Yavsc.Resources.YavscLocalisation.fr.resx | 7 ++++ .../FrontOffice/FrontOfficeIndexViewModel.cs | 13 ++++++++ Yavsc/Views/FrontOffice/Index.cshtml | 33 ++++++++++++++++++- 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 Yavsc/ViewModels/FrontOffice/FrontOfficeIndexViewModel.cs diff --git a/Yavsc/Controllers/FrontOfficeController.cs b/Yavsc/Controllers/FrontOfficeController.cs index c895a8c9..fc28846f 100644 --- a/Yavsc/Controllers/FrontOfficeController.cs +++ b/Yavsc/Controllers/FrontOfficeController.cs @@ -8,6 +8,8 @@ using Microsoft.Extensions.Logging; using Yavsc.Models.Booking; using Yavsc.Helpers; using System; +using Yavsc.ViewModels.FrontOffice; +using System.Security.Claims; namespace Yavsc.Controllers { @@ -27,10 +29,20 @@ namespace Yavsc.Controllers } public ActionResult Index() { - var latestPosts = _context.Blogspot.Where( - x => x.Visible == true - ).OrderBy(x => x.Modified).Take(25).ToArray(); - return View(latestPosts); + var uid = User.GetUserId(); + var now = DateTime.Now; + + var model = new FrontOfficeIndexViewModel{ + EstimateToProduceCount = _context.Commands.Where(c => c.PerformerId == uid && c.EventDate > now + && c.ValidationDate == null && !_context.Estimates.Any(e=>(e.CommandId == c.Id && e.ProviderValidationDate != null))).Count(), + EstimateToSignAsProCount = _context.Commands.Where(c => ( c.PerformerId == uid && c.EventDate > now + && c.ValidationDate == null && _context.Estimates.Any(e=>(e.CommandId == c.Id && e.ProviderValidationDate != null)))).Count(), + EstimateToSignAsCliCount = _context.Estimates.Where(e=>e.ClientId == uid && e.ClientValidationDate == null) .Count(), + BillToSignAsProCount = 0, + BillToSignAsCliCount = 0, + NewPayementsCount = 0 + }; + return View(model); } [Route("Book/{id?}"), HttpGet] diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx index 5cbdb395..0f205f8e 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx @@ -203,6 +203,13 @@ entrées Estimer Devis non trouvé + Demandes de Devis en souffrance + Devis à valider + Devis à accèpter ou refuser + 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 diff --git a/Yavsc/ViewModels/FrontOffice/FrontOfficeIndexViewModel.cs b/Yavsc/ViewModels/FrontOffice/FrontOfficeIndexViewModel.cs new file mode 100644 index 00000000..bd5225bf --- /dev/null +++ b/Yavsc/ViewModels/FrontOffice/FrontOfficeIndexViewModel.cs @@ -0,0 +1,13 @@ +namespace Yavsc.ViewModels.FrontOffice +{ + public class FrontOfficeIndexViewModel + { + public int EstimateToProduceCount { get; set; } + public int EstimateToSignAsProCount { get; set; } + public int EstimateToSignAsCliCount { get; set; } + public int BillToSignAsProCount { get; set; } + public int BillToSignAsCliCount { get; set; } + public int NewPayementsCount { get; set; } + + } +} \ No newline at end of file diff --git a/Yavsc/Views/FrontOffice/Index.cshtml b/Yavsc/Views/FrontOffice/Index.cshtml index dd9ee17d..bc2a15b5 100644 --- a/Yavsc/Views/FrontOffice/Index.cshtml +++ b/Yavsc/Views/FrontOffice/Index.cshtml @@ -1,7 +1,38 @@ - +@model Yavsc.ViewModels.FrontOffice.FrontOfficeIndexViewModel @{ ViewData["Title"] = "Front office"; }

Index

+
+
@SR["EstimateToProduce"] +
+
@Html.DisplayFor(m=>m.EstimateToProduceCount) +
+ +
@SR["EstimateToSignAsPro"] +
+
@Html.DisplayFor(m=>m.EstimateToSignAsProCount) +
+ +
@SR["EstimateToSignAsCli"] +
+
@Html.DisplayFor(m=>m.EstimateToSignAsCliCount) +
+ +
@SR["BillToSignAsPro"] +
+
@Html.DisplayFor(m=>m.BillToSignAsProCount) +
+ +
@SR["BillToSignAsCli"] +
+
@Html.DisplayFor(m=>m.BillToSignAsCliCount) +
+ +
@SR["PayementsDone"] +
+
@Html.DisplayFor(m=>m.NewPayementsCount) +
+