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,44 @@
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 InventoryController : ControllerBase
{
private readonly AppDbContext _context;
public InventoryController(AppDbContext context)
{
_context = context;
}
public ActionResult Index()
{
return View();
}
public JsonResult All()
{
var customerModels = _context.Inventories
.OrderByDescending(x => x.InventoryType.Name)
.ProjectTo<InventoryViewModel>();
return BetterJson(customerModels.ToArray());
}
public JsonResult Arrival(AddCustomerForm form)
{
var customer = Mapper.Map<Customer>(form);
_context.Customers.Add(customer);
_context.SaveChanges();
var model = Mapper.Map<CustomerViewModel>(customer);
return BetterJson(model);
}
}
}