Remove CRM bits
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using InventoryTraker.Web.Core;
|
||||
using InventoryTraker.Web.Data;
|
||||
using InventoryTraker.Web.Models;
|
||||
|
||||
namespace InventoryTraker.Web.Controllers
|
||||
{
|
||||
public class CustomerController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public CustomerController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public JsonResult All()
|
||||
{
|
||||
var customerModels = _context.Customers
|
||||
.OrderByDescending(x => x.CreateDate)
|
||||
.ProjectTo<CustomerViewModel>();
|
||||
|
||||
return BetterJson(customerModels.ToArray());
|
||||
}
|
||||
|
||||
public JsonResult Add(AddCustomerForm form)
|
||||
{
|
||||
var customer = Mapper.Map<Customer>(form);
|
||||
_context.Customers.Add(customer);
|
||||
_context.SaveChanges();
|
||||
|
||||
var model = Mapper.Map<CustomerViewModel>(customer);
|
||||
return BetterJson(model);
|
||||
}
|
||||
|
||||
public JsonResult Update(EditCustomerForm form)
|
||||
{
|
||||
var target = _context.Customers.Find(form.Id);
|
||||
|
||||
Mapper.Map(form, target);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
var updatedCustomer = _context.Customers.ProjectTo<CustomerViewModel>().Single(x => x.Id == form.Id);
|
||||
|
||||
return BetterJson(updatedCustomer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using InventoryTraker.Web.Core;
|
||||
using InventoryTraker.Web.Data;
|
||||
using InventoryTraker.Web.Models;
|
||||
|
||||
namespace InventoryTraker.Web.Controllers
|
||||
{
|
||||
public class OpportunityController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public OpportunityController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ViewResult Index()
|
||||
{
|
||||
var models = _context.Opportunities.ProjectTo<OpportunityViewModel>().ToArray();
|
||||
return View(models);
|
||||
}
|
||||
|
||||
public JsonResult Add(AddOpportunityForm form)
|
||||
{
|
||||
var customer = _context.Customers.Include(x => x.Opportunities).Single(x => x.Id == form.CustomerId);
|
||||
|
||||
var opportunity = Mapper.Map<Opportunity>(form);
|
||||
|
||||
customer.Opportunities.Add(opportunity);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
var model = Mapper.Map<CustomerOpportunityViewModel>(opportunity);
|
||||
|
||||
return BetterJson(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using InventoryTraker.Web.Core;
|
||||
using InventoryTraker.Web.Data;
|
||||
using InventoryTraker.Web.Models;
|
||||
|
||||
namespace InventoryTraker.Web.Controllers
|
||||
{
|
||||
public class RiskController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public RiskController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ViewResult Index()
|
||||
{
|
||||
var models = _context.Risks.ProjectTo<RiskViewModel>().ToArray();
|
||||
return View(models);
|
||||
}
|
||||
|
||||
public JsonResult Add(AddRiskForm form)
|
||||
{
|
||||
var customer = _context.Customers.Include(x => x.Risks).Single(x => x.Id == form.CustomerId);
|
||||
|
||||
var risk = Mapper.Map<Risk>(form);
|
||||
|
||||
customer.Risks.Add(risk);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
var model = Mapper.Map<CustomerRiskViewModel>(risk);
|
||||
|
||||
return BetterJson(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user