Initiate InventoyTypes from a xlxs

Arrival mostly working
This commit is contained in:
2016-08-22 11:03:00 -04:00
parent 7e4d8a6d2a
commit 53ed1b3af9
40 changed files with 798 additions and 208 deletions
@@ -9,12 +9,13 @@ namespace InventoryTraker.Web.Models
public class InventoryAddForm : IMapTo<Inventory>
{
[HiddenInput(DisplayValue = false)]
public string InventoryTypeId { get; set; }
[Required]
public int InventoryTypeId { get; set; }
[Required]
public DateTime ExpirationDate { get; set; }
[Required]
[Required, Range(1, int.MaxValue, ErrorMessage = "Quantity must be greater than 0")]
public int Quantity { get; set; }
[Required, Display(Name = "Arrival Date")]
@@ -5,7 +5,9 @@ namespace InventoryTraker.Web.Models
{
public class InventoryTypeViewModel : IMapFrom<InventoryType>
{
public string Id { get; set; }
public int Id { get; set; }
public string Identifier { get; set; }
public string Name { get; set; }
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using AutoMapper;
using Heroic.AutoMapper;
using InventoryTraker.Web.Core;
@@ -23,13 +24,19 @@ namespace InventoryTraker.Web.Models
public DateTime ExpirationDate { get; set; }
public DateTime AddedDate { get; set; }
public string Memo { get; set; }
public void CreateMappings(IMapperConfiguration configuration)
{
configuration.CreateMap<Inventory, InventoryViewModel>()
.ForMember(d => d.Name, opt => opt.MapFrom(s => s.InventoryType.Name))
.ForMember(d => d.UnitsPerCase, opt => opt.MapFrom(s => s.InventoryType.UnitsPerCase))
.ForMember(d => d.ContainerType, opt => opt.MapFrom(s => s.InventoryType.ContainerType))
.ForMember(d => d.WeightPerCase, opt => opt.MapFrom(s => s.InventoryType.WeightPerCase))
.ForMember(d => d.PricePerCase, opt => opt.MapFrom(s => s.InventoryType.PricePerCase));
.ForMember(d => d.PricePerCase, opt => opt.MapFrom(s => s.InventoryType.PricePerCase))
.ForMember(d => d.AddedDate, opt => opt.MapFrom(s => s.AddedDate));
}
}
}