InventoryType from XML
Transaction updates
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace InventoryTraker.Web.Models
|
||||
{
|
||||
public class InventoryQuantityForm
|
||||
{
|
||||
[Required]
|
||||
public int InventoryId { get; set; }
|
||||
|
||||
[Required, Range(1, int.MaxValue, ErrorMessage = "Quantity must be greater than 0")]
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
|
||||
public class InventoryDistributeForm
|
||||
{
|
||||
public IList<InventoryQuantityForm> InventoryQuantities { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Destination { get; set; }
|
||||
|
||||
[Required, Display(Name = "Distributed Date")]
|
||||
public DateTime DistributedDate { get; set; }
|
||||
|
||||
public string Memo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Heroic.AutoMapper;
|
||||
using InventoryTraker.Web.Core;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
using Heroic.AutoMapper;
|
||||
using InventoryTraker.Web.Core;
|
||||
|
||||
namespace InventoryTraker.Web.Models
|
||||
{
|
||||
public class TransactionViewModel : IMapFrom<Transaction>, IHaveCustomMappings
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public int UnitsPerCase { get; set; }
|
||||
public string ContainerType { get; set; }
|
||||
|
||||
[Required]
|
||||
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,
|
||||
opt => opt.MapFrom(s => s.Inventory.InventoryType.Name))
|
||||
.ForMember(d => d.UnitsPerCase,
|
||||
opt => opt.MapFrom(s => s.Inventory.InventoryType.UnitsPerCase))
|
||||
.ForMember(d => d.ContainerType,
|
||||
opt => opt.MapFrom(s => s.Inventory.InventoryType.ContainerType));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user