c# - My program is not updating mongo db -


i new in mvc. doing program edits existing records in mongodb. program not updating record.

this edit method:

[httppost] public async task<actionresult> edit(biocardmodel model) {      await _biocardservices.updatebiocard( model.cardid ,model);      return redirecttoaction("index"); }  

this method updates record in mongo db

public async task updatebiocard(guid value, [frombody]biocardmodel card) {     var db = connecttomongo();     var collection = db.getcollection<biocardmodel>(_collection);      var filter = builders<biocardmodel>.filter.eq("cardid", value);     var update = builders<biocardmodel>.update         .set(b => b.name, card.name)         .set(b => b.firstname, card.firstname)         .set(b => b.lastname, card.lastname)         .set(b => b.title, card.title)         .set(b => b.lifespan, card.lifespan)         .set(b => b.bio, card.bio)         .set(b => b.bio, card.anecdote)         .set(b => b.imagefront, card.imagefront)         .set(b => b.imageback, card.imageback);     await collection.updateoneasync(filter, update); } 

my view simple form populated record data.

it looks view code missing post, i'm going guess view doesn't contain necessary fields model. make sure rendering fields want included in post view.

you can use hidden fields output primary key form ensure gets posted server. here's link explanation on difference between hidden fields in asp.net mvc

what difference between html.hidden , html.hiddenfor


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -