Guest User

Guest User

  • Tech Writer
  • 64
  • 2.8k

Many to Many Table Controller Create

Apr 25 2021 11:16 AM
I have a project for school to make an auction website.
I made it in ASP.NET MVC  database first (with edmx things) 
So i have in my project 3 tables + some others:
  • Auctions
  • Users
  • Users_Offers with : IdUsersOffers, AmountBid, DateBid, IdUser, IdAuction
  
 
That's the auction Page .
 
How can i write the controller for User_Offers  to add bid  for the current auction but to have DateBid = Datetime.Now; , IdAuction = current auction ; IdUser = User.identity.getuserid() when i pressed the "Bid Now", and only to write the amount that i want to bid in the input shown there?
 
I don't mind if when I press the "Bid Now" to redirect me to another page like this:
 
 
But i want the informations from the previous page (IdAuction) to be saved
 
I tried to make it automatically with entity framework but the result was giving me a list with all auctions and all users and I want only the current auction and current user authenticated.
 
 

Answers (5)