Estoy desarrollando una aplicación con ASP.NET MVC usando Visual Studio 2017 aplicando el enfoque de Code First. Tengo tres clases (tablas) en el modelo, una es un repositorio llamado DataBase y una interfaz IDataBase. Estoy almacenando datos en la memoria sin usar db. Esta es mi clase "FacturadeArticulo"
public class FacturadeArticulo {
public int ID { get; set; }
public Nullable<int> InvoiceID { get; set; }
public string ArticleNumber { get; set; }
[DataType(DataType.MultilineText)]
public string ArticleDescription { get; set; }
public Nullable<int> Quantity { get; set; }
public Nullable<decimal> PricePerUnit { get; set; }
public Nullable<decimal> TaxPercentage { get; set; }
public Nullable<decimal> NettoAmount { get; set; }
public Nullable<decimal> BruttoAmount { get; set; }
public virtual Supplier Supplier { get; set; }
public virtual Invoice Invoice { get; set; }}
Mi pregunta es: Como puedo calcular los valores en esta Classe: (Quantity*PricePerUnit =NettoAmount) y ((PricePerUnit * TaxPercentage) / 100 + PricePerUnit*Quantity=BruttoAmount). ¿Es esto posible? Repositorio DataBase:
public class DataBase:IDataBase{
private static List<Supplier> suppliers = new List<Supplier>();
private static List<Invoice> invoices = new List<Invoice>();
private static List<FacturadeArticulo> facturadeArticulos = new List<FacturadeArticulo>();
private static int _nextId = 1;
public DataBase()
{
}
public FacturadeArticulo Add(FacturadeArticulo item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
// TO DO : Code to save record into database
item.ID = _nextId++;
facturadeArticulos.Add(item);
return item;
} public IEnumerable<FacturadeArticulo> getAll()
{
return facturadeArticulos;
}