This commit is contained in:
2016-08-08 14:47:35 -04:00
commit 0b0cb7c73a
156 changed files with 114318 additions and 0 deletions
@@ -0,0 +1,47 @@
using System;
using System.Linq;
using System.Web.Mvc;
using AutoMapper.QueryableExtensions;
using InventoryTraker.Web.Data;
using InventoryTraker.Web.Models;
using InventoryTraker.Web.Utilities;
namespace InventoryTraker.Web.Controllers
{
public class ReportController : ControllerBase
{
private readonly AppDbContext _context;
public ReportController(AppDbContext context)
{
_context = context;
}
public ActionResult Index()
{
return View();
}
public JsonResult NewCustomers()
{
var startOfMonth = DateTime.Today.ToStartOfMonth();
var endOfMonth = DateTime.Today.ToEndOfMonth();
var customers = _context.Customers.Where(x => x.CreateDate >= startOfMonth && x.CreateDate <= endOfMonth)
.ProjectTo<NewCustomerReportViewModel>().ToArray();
return BetterJson(customers);
}
public JsonResult LostCustomers()
{
var startOfMonth = DateTime.Today.ToStartOfMonth();
var endOfMonth = DateTime.Today.ToEndOfMonth();
var customers = _context.Customers.Where(x => x.TerminationDate >= startOfMonth && x.TerminationDate <= endOfMonth)
.ProjectTo<LostCustomerReportViewModel>().ToArray();
return Json(customers);
}
}
}