Initiate InventoyTypes from a xlxs
Arrival mostly working
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Heroic.AutoMapper;
|
||||
using InventoryTraker.Web;
|
||||
using InventoryTraker.Web.Controllers;
|
||||
|
||||
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(AutoMapperConfig), "Configure")]
|
||||
namespace InventoryTraker.Web
|
||||
@@ -12,9 +13,9 @@ namespace InventoryTraker.Web
|
||||
// You can customize this by passing in a lambda to filter the assemblies by name,
|
||||
// like so:
|
||||
//HeroicAutoMapperConfigurator.LoadMapsFromCallerAndReferencedAssemblies(x => x.Name.StartsWith("YourPrefix"));
|
||||
HeroicAutoMapperConfigurator.LoadMapsFromCallerAndReferencedAssemblies();
|
||||
//HeroicAutoMapperConfigurator.LoadMapsFromCallerAndReferencedAssemblies();
|
||||
//If you run into issues with the maps not being located at runtime, try using this method instead:
|
||||
//HeroicAutoMapperConfigurator.LoadMapsFromAssemblyContainingTypeAndReferencedAssemblies<SomeControllerOrTypeInYourWebProject>();
|
||||
HeroicAutoMapperConfigurator.LoadMapsFromAssemblyContainingTypeAndReferencedAssemblies<ControllerBase>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace InventoryTraker.Web
|
||||
{
|
||||
public static void RegisterBundles(BundleCollection bundles)
|
||||
{
|
||||
bundles.Add(new StyleBundle("~/Content/all.css")
|
||||
bundles.Add(new StyleBundle("~/Content/all-styles")
|
||||
.Include("~/Content/font-awesome.css")
|
||||
.Include("~/Content/bootstrap.css")
|
||||
.Include("~/Content/sb-admin.css")
|
||||
@@ -14,7 +14,7 @@ namespace InventoryTraker.Web
|
||||
.Include("~/Content/ui-grid.css")
|
||||
);
|
||||
|
||||
bundles.Add(new ScriptBundle("~/js/all.js")
|
||||
bundles.Add(new ScriptBundle("~/js/all-javascript")
|
||||
.Include("~/Scripts/jquery-1.9.1.js")
|
||||
.Include("~/Scripts/bootstrap.js")
|
||||
.Include("~/Scripts/angular.js")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Humanizer;
|
||||
using InventoryTraker.Web.Core;
|
||||
using InventoryTraker.Web.Data;
|
||||
@@ -47,6 +49,10 @@ namespace InventoryTraker.Web
|
||||
|
||||
if (!context.Inventories.Any())
|
||||
{
|
||||
AddInventoryTypes(context);
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
AddInventory(context);
|
||||
|
||||
context.SaveChanges();
|
||||
@@ -65,48 +71,59 @@ namespace InventoryTraker.Web
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddInventoryTypes(AppDbContext context)
|
||||
{
|
||||
var folder = HttpContext.Current.Server.MapPath("~/App_Data");
|
||||
var inventoryTypeFile = Path.Combine(folder, "InventoryTypeSeedData.xlsx");
|
||||
var parser = new InventoryTypeParser(new FileInfo(inventoryTypeFile));
|
||||
foreach (var inventoryType in parser.Parse())
|
||||
{
|
||||
context.InventoryTypes.Add(inventoryType);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddInventory(AppDbContext context)
|
||||
{
|
||||
var peanutButterSmooth = new InventoryType
|
||||
{
|
||||
ContainerType = "18 oz jars",
|
||||
Name = "Peanut Butter Smth 18",
|
||||
Id = "100395",
|
||||
UnitsPerCase = 12,
|
||||
PricePerCase = 14.55M,
|
||||
WeightPerCase = 13.5
|
||||
};
|
||||
context.InventoryTypes.Add(peanutButterSmooth);
|
||||
|
||||
var beanInventoryType = new InventoryType
|
||||
{
|
||||
ContainerType = "#300 cans",
|
||||
Name = "Beans, Veg 300",
|
||||
Id = "100363",
|
||||
UnitsPerCase = 24,
|
||||
PricePerCase = 10.18M,
|
||||
WeightPerCase = 24
|
||||
};
|
||||
context.InventoryTypes.Add(beanInventoryType);
|
||||
|
||||
var corn = new InventoryType
|
||||
{
|
||||
ContainerType = "#300 cans",
|
||||
Name = "Corn Kernel 300",
|
||||
Id = "100311",
|
||||
UnitsPerCase = 24,
|
||||
PricePerCase = 10.03M,
|
||||
WeightPerCase = 22.9
|
||||
};
|
||||
context.InventoryTypes.Add(corn);
|
||||
var pork = context.InventoryTypes.First(it => it.Identifier == "100139");
|
||||
var beans = context.InventoryTypes.First(it => it.Identifier == "100363");
|
||||
var pb = context.InventoryTypes.First(it => it.Identifier == "100395");
|
||||
|
||||
context.Inventories.Add(new Inventory
|
||||
{
|
||||
InventoryType = beanInventoryType,
|
||||
InventoryType = pork,
|
||||
ExpirationDate = DateTime.Now.AddYears(1).AtMidnight(),
|
||||
Memo = "French cut",
|
||||
AddedDate = DateTime.Now.AddDays(-1).AtMidnight(),
|
||||
Memo = "Hormel",
|
||||
Quantity = 10,
|
||||
Transactions = new List<Transaction> { new Transaction { AddedQuantity = 10, Memo = "arrival", TransactionDate = DateTime.Now} }
|
||||
Transactions = new List<Transaction> { new Transaction
|
||||
{
|
||||
AddedQuantity = 10, Memo = "arrival", TransactionDate = DateTime.Now.AddDays(-1).AtMidnight(), Timestamp = DateTime.Now
|
||||
}}
|
||||
});
|
||||
|
||||
context.Inventories.Add(new Inventory
|
||||
{
|
||||
InventoryType = beans,
|
||||
ExpirationDate = DateTime.Now.AddMonths(4).AtMidnight(),
|
||||
AddedDate = DateTime.Now.AddMonths(-2).AtMidnight(),
|
||||
Memo = "Cut",
|
||||
Quantity = 15,
|
||||
Transactions = new List<Transaction> { new Transaction
|
||||
{
|
||||
AddedQuantity = 15, Memo = "arrival", TransactionDate = DateTime.Now.AddMonths(-2).AtMidnight(), Timestamp = DateTime.Now
|
||||
}}
|
||||
});
|
||||
|
||||
context.Inventories.Add(new Inventory
|
||||
{
|
||||
InventoryType = pb,
|
||||
ExpirationDate = DateTime.Now.AddDays(300).AtMidnight(),
|
||||
AddedDate = DateTime.Now.AddDays(-34).AtMidnight(),
|
||||
Quantity = 700,
|
||||
Transactions = new List<Transaction> { new Transaction
|
||||
{
|
||||
AddedQuantity = 700, Memo = "arrival", TransactionDate = DateTime.Now.AddDays(-34).AtMidnight(), Timestamp = DateTime.Now
|
||||
}}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user