Hi,
I use asp net core mvc (2.0)
I have three tables which have relations:
CREATE TABLE [dbo].[ProdukteArtikel] ( [ID] INT IDENTITY (1, 1) NOT NULL, [Price] DECIMAL (18, 2) NULL, ... CONSTRAINT [PK_ProdukteArtikel] PRIMARY KEY CLUSTERED ([ID] ASC) ); CREATE TABLE [dbo].[Produkte] ( [ID] INT IDENTITY (1, 1) NOT NULL, ... CONSTRAINT [PK_Produkte] PRIMARY KEY CLUSTERED ([ID] ASC) ); CREATE TABLE [dbo].[ProdukteArtikelRelation] ( [ID] INT IDENTITY (1, 1) NOT NULL, [Produkt] INT NULL, [ProduktArtikel] INT NULL, [Piece] INT NULL, [Price] DECIMAL (18, 2) NULL, [Total] DECIMAL (18, 2) NULL, CONSTRAINT [PK_ProdukteArtikelRelation] PRIMARY KEY CLUSTERED ([ID] ASC), CONSTRAINT [FK_ProdukteArtikelRelation_ProdukteArtikel] FOREIGN KEY ([ProduktArtikel]) REFERENCES [dbo].[ProdukteArtikel] ([ID]), CONSTRAINT [FK_ProdukteArtikelRelation_Produkte] FOREIGN KEY ([Produkt]) REFERENCES [dbo].[Produkte] ([ID]) );
In View/ProdukteArtikelRelation/Create I write Data to dbo.ProdukteArtikelRelation.
There I have only 3 Fields: "Produkt", "ProduktArtikel" and "Piece".
"Produkt" and "ProduktArtikel" are SelectLists. For "Piece" there is a entry field.
My "ProdukteArtikelRelation" Controller looks like:
[HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Create([Bind("Id,Produkt,ProduktArtikel,Piece,Price,Total")] ProdukteArtikelRelation produkteArtikelRelation)
Is there a possibility to read the "Price" from "ProdukteArtikel", make a short calculation and store these values in "Price" and "Total"?
Thanks