main
Paul Schneider 9 years ago
parent c59ac14ae9
commit 8a4a778322
1 changed files with 23 additions and 27 deletions

@ -1,18 +1,18 @@
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Yavsc.Models;
using System.Linq;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Yavsc.Models.Booking;
using Yavsc.Helpers;
using System; using System;
using Yavsc.ViewModels.FrontOffice; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using Helpers;
using Models;
using Models.Booking;
using ViewModels.FrontOffice;
public class FrontOfficeController : Controller public class FrontOfficeController : Controller
{ {
ApplicationDbContext _context; ApplicationDbContext _context;
@ -31,13 +31,14 @@ namespace Yavsc.Controllers
{ {
var uid = User.GetUserId(); var uid = User.GetUserId();
var now = DateTime.Now; var now = DateTime.Now;
var model = new FrontOfficeIndexViewModel{ 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(), EstimateToProduceCount = _context.Commands.Where(c => c.PerformerId == uid && c.EventDate > now
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(),
&& 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
EstimateToSignAsCliCount = _context.Estimates.Where(e=>e.ClientId == uid && e.ClientValidationDate == null) .Count(), && 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, BillToSignAsProCount = 0,
BillToSignAsCliCount = 0, BillToSignAsCliCount = 0,
NewPayementsCount = 0 NewPayementsCount = 0
@ -52,13 +53,8 @@ namespace Yavsc.Controllers
{ {
throw new NotImplementedException("No Activity code"); throw new NotImplementedException("No Activity code");
} }
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == id); ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
var result = _context.Performers var result = _context.ListPerformers(id);
.Include(p=>p.Activity)
.Include(p=>p.Performer)
.Include(p=>p.Performer.Posts)
.Include(p=>p.Performer.Devices)
.Where(p => p.Active && p.Activity.Any(u=>u.DoesCode==id)).OrderBy( x => x.Rate ).ToList();
return View(result); return View(result);
} }
@ -89,7 +85,7 @@ namespace Yavsc.Controllers
return View("Index"); return View("Index");
} }
ViewBag.Activities = _context.ActivityItems(null); ViewBag.Activities = _context.ActivityItems(null);
return View("Book",_context.Performers.Include(p => p.Performer).Where return View("Book", _context.Performers.Include(p => p.Performer).Where
(p => p.Active).OrderBy( (p => p.Active).OrderBy(
x => x.MinDailyCost x => x.MinDailyCost
)); ));
@ -108,7 +104,7 @@ namespace Yavsc.Controllers
return View("Estimate.tex", estimate); return View("Estimate.tex", estimate);
} }
[Authorize,Route("Estimate-{id}.pdf")] [Authorize, Route("Estimate-{id}.pdf")]
public IActionResult EstimatePdf(long id) public IActionResult EstimatePdf(long id)
{ {
ViewBag.TempDir = Startup.SiteSetup.TempDir; ViewBag.TempDir = Startup.SiteSetup.TempDir;
@ -118,10 +114,10 @@ namespace Yavsc.Controllers
.Include(x => x.Query.PerformerProfile) .Include(x => x.Query.PerformerProfile)
.Include(x => x.Query.PerformerProfile.OrganizationAddress) .Include(x => x.Query.PerformerProfile.OrganizationAddress)
.Include(x => x.Query.PerformerProfile.Performer) .Include(x => x.Query.PerformerProfile.Performer)
.Include(e => e.Bill).FirstOrDefault(x => x.Id == id); .Include(e => e.Bill).FirstOrDefault(x => x.Id == id);
if (estimate==null) if (estimate == null)
throw new Exception("No data"); throw new Exception("No data");
return View("Estimate.pdf",estimate); return View("Estimate.pdf", estimate);
} }
[Authorize] [Authorize]
@ -135,18 +131,18 @@ namespace Yavsc.Controllers
public IActionResult EstimateClientValidation() public IActionResult EstimateClientValidation()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
[Authorize] [Authorize]
public IActionResult BillValidation() public IActionResult BillValidation()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
[Authorize] [Authorize]
public IActionResult BillAcquitment() public IActionResult BillAcquitment()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

Loading…