yavsc/Yavsc/Controllers/FrontOfficeController.cs

134 lines
4.6 KiB
C#

using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Identity;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
8 years ago
using System;
8 years ago
using System.Linq;
using System.Security.Claims;
namespace Yavsc.Controllers
{
8 years ago
using Helpers;
using Microsoft.Extensions.Localization;
8 years ago
using Models;
using ViewModels.FrontOffice;
8 years ago
public class FrontOfficeController : Controller
{
ApplicationDbContext _context;
UserManager<ApplicationUser> _userManager;
ILogger _logger;
IStringLocalizer _SR;
public FrontOfficeController(ApplicationDbContext context,
UserManager<ApplicationUser> userManager,
ILoggerFactory loggerFactory,
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR)
{
_context = context;
_userManager = userManager;
_logger = loggerFactory.CreateLogger<FrontOfficeController>();
_SR = SR;
}
public ActionResult Index()
{
var uid = User.GetUserId();
var now = DateTime.Now;
8 years ago
var model = new FrontOfficeIndexViewModel
{
7 years ago
EstimateToProduceCount = _context.RdvQueries.Where(c => c.PerformerId == uid && c.EventDate > now
8 years ago
&& c.ValidationDate == null && !_context.Estimates.Any(e => (e.CommandId == c.Id && e.ProviderValidationDate != null))).Count(),
7 years ago
EstimateToSignAsProCount = _context.RdvQueries.Where(c => (c.PerformerId == uid && c.EventDate > now
8 years ago
&& 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);
}
8 years ago
[AllowAnonymous]
public ActionResult Profiles(string id)
{
8 years ago
if (id == null)
{
8 years ago
throw new NotImplementedException("No Activity code");
}
8 years ago
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
var result = _context.ListPerformers(id);
return View(result);
}
8 years ago
[AllowAnonymous]
public ActionResult HairCut(string id)
{
8 years ago
if (id == null)
{
throw new NotImplementedException("No Activity code");
}
8 years ago
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
var result = _context.ListPerformers(id);
8 years ago
return View(result);
}
8 years ago
8 years ago
[Produces("text/x-tex"), Authorize, Route("estimate-{id}.tex")]
public ViewResult EstimateTex(long id)
{
8 years ago
var estimate = _context.Estimates.Include(x => x.Query)
.Include(x => x.Query.Client)
.Include(x => x.Query.PerformerProfile)
.Include(x => x.Query.PerformerProfile.OrganizationAddress)
.Include(x => x.Query.PerformerProfile.Performer)
.Include(e => e.Bill).FirstOrDefault(x => x.Id == id);
8 years ago
Response.ContentType = "text/x-tex";
return View("Estimate.tex", estimate);
}
8 years ago
8 years ago
[Authorize, Route("Estimate-{id}.pdf")]
8 years ago
public IActionResult EstimatePdf(long id)
{
8 years ago
ViewBag.TempDir = Startup.SiteSetup.TempDir;
ViewBag.BillsDir = Startup.UserBillsDirName;
var estimate = _context.Estimates.Include(x => x.Query)
.Include(x => x.Query.Client)
.Include(x => x.Query.PerformerProfile)
.Include(x => x.Query.PerformerProfile.OrganizationAddress)
.Include(x => x.Query.PerformerProfile.Performer)
8 years ago
.Include(e => e.Bill).FirstOrDefault(x => x.Id == id);
if (estimate == null)
8 years ago
throw new Exception("No data");
8 years ago
return View("Estimate.pdf", estimate);
}
8 years ago
[Authorize]
public IActionResult EstimateProValidation()
{
throw new NotImplementedException();
}
[Authorize]
public IActionResult EstimateClientValidation()
{
throw new NotImplementedException();
8 years ago
8 years ago
}
[Authorize]
public IActionResult BillValidation()
{
throw new NotImplementedException();
8 years ago
8 years ago
}
[Authorize]
public IActionResult BillAcquitment()
{
throw new NotImplementedException();
}
8 years ago
}
8 years ago
}