Start to implement a FrontOffice index

This commit is contained in:
Paul Schneider 2017-01-12 10:12:28 +01:00
commit da57f627fb
4 changed files with 68 additions and 5 deletions

View file

@ -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]