Add transaction type

This commit is contained in:
2016-08-31 12:08:22 -04:00
parent c86d7fb1ed
commit f5e438e994
8 changed files with 95 additions and 38 deletions
@@ -17,36 +17,39 @@ namespace InventoryTraker.Web.Models
public DateTime ExpirationDate { get; set; }
public DateTime AddedDate { get; set; }
[Required]
public string TransactionType { get; set; }
public int PreviousQuantity { get; set; }
public int AddedQuantity { get; set; }
[Required]
public int RemovedQuantity { get; set; }
[Required]
public int CurrentQuantity { get; set; }
[Required]
public DateTime TransactionDate { get; set; }
public string Memo { get; set; }
[Required]
public DateTime Timestamp { get; set; }
public void CreateMappings(IMapperConfiguration configuration)
{
configuration.CreateMap<Transaction, TransactionViewModel>()
.ForMember(d => d.Name,
.ForMember(d => d.Name,
opt => opt.MapFrom(s => s.Inventory.InventoryType.Name))
.ForMember(d => d.ExpirationDate,
.ForMember(d => d.ExpirationDate,
opt => opt.MapFrom(s => s.Inventory.ExpirationDate))
.ForMember(d => d.AddedDate,
.ForMember(d => d.AddedDate,
opt => opt.MapFrom(s => s.Inventory.AddedDate))
.ForMember(d => d.UnitsPerCase,
.ForMember(d => d.UnitsPerCase,
opt => opt.MapFrom(s => s.Inventory.InventoryType.UnitsPerCase))
.ForMember(d => d.ContainerType,
opt => opt.MapFrom(s => s.Inventory.InventoryType.ContainerType));
.ForMember(d => d.ContainerType,
opt => opt.MapFrom(s => s.Inventory.InventoryType.ContainerType))
.ForMember(d => d.TransactionType,
opt => opt.MapFrom(s => s.TransactionType.ToString()))
.ForMember(d => d.PreviousQuantity,
opt => opt.MapFrom(s => s.CurrentQuantity - s.AddedQuantity + s.RemovedQuantity));
}
}
}