public class Transaction_GeneralInfo
{
[Key]
public string CompanyName { get; set; }
public int VNumber { get; set; }
}
public class Accounting_PendingBills
{
[Key]
public String Branch { get; set; }
public string Currency { get; set; }
public string CompanyName { get; set; }
}
public class ReceiptsViewModel
{
public String Branch { get; set; }
public string Currency { get; set; }
public int VNumber { get; set; }
public string CompanyName { get; set; }
}
public class ReceiptsDbContext : DbContext
{
public DbSet<Accounting_PendingBills> pendings { get; set; }
public DbSet<Transaction_GeneralInfo> transactionGeneralInfo { get; set; }
}
public ActionResult Index(ReceiptsViewModel receiptsModel, string Command)
{
if (Command == "Save")
{
ReceiptsDbContext db = new ReceiptsDbContext();
var transaction = new Transaction_GeneralInfo()
{
CompanyName = receiptsModel.CompanyName,
VNumber = receiptsModel.VNumber
};
var pending = new Accounting_PendingBills()
{
Branch = receiptsModel.Branch,
Currency = receiptsModel.Currency,
CompanyName = receiptsModel.CompanyName
};
db.transactionGeneralInfo.Add(transaction);
db.pendings.Add(pending);
db.SaveChanges();
}