64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using AutoMapper;
|
|
using InventoryTraker.Web.Core;
|
|
|
|
namespace InventoryTraker.Web.Models
|
|
{
|
|
public class TransactionViewModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
public string InventoryId { get; set; }
|
|
|
|
public string ProgramName { get; set; }
|
|
|
|
public string ProgramSubtype { get; set; }
|
|
|
|
public string Description { get; set; }
|
|
|
|
public DateTime ShredReadyDate { get; set; }
|
|
|
|
public DateTime AddedDate { get; set; }
|
|
|
|
public string TransactionType { get; set; }
|
|
|
|
public int PreviousQuantity { get; set; }
|
|
|
|
public int AddedQuantity { get; set; }
|
|
|
|
public int RemovedQuantity { get; set; }
|
|
|
|
public int CurrentQuantity { get; set; }
|
|
|
|
public DateTime TransactionDate { get; set; }
|
|
|
|
public string Memo { get; set; }
|
|
|
|
public DateTime Timestamp { get; set; }
|
|
|
|
public class AutoMapperProfile : Profile
|
|
{
|
|
public AutoMapperProfile()
|
|
{
|
|
CreateMap<Transaction, TransactionViewModel>()
|
|
.ForMember(d => d.InventoryId,
|
|
opt => opt.MapFrom(s => s.Inventory.Id))
|
|
.ForMember(d => d.ProgramName,
|
|
opt => opt.MapFrom(s => s.Inventory.ProgramName))
|
|
.ForMember(d => d.ProgramSubtype,
|
|
opt => opt.MapFrom(s => s.Inventory.ProgramSubtype))
|
|
.ForMember(d => d.Description,
|
|
opt => opt.MapFrom(s => s.Inventory.Description))
|
|
.ForMember(d => d.ShredReadyDate,
|
|
opt => opt.MapFrom(s => s.Inventory.ShredReadyDate))
|
|
.ForMember(d => d.AddedDate,
|
|
opt => opt.MapFrom(s => s.Inventory.AddedDate))
|
|
.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));
|
|
}
|
|
}
|
|
}
|
|
} |