I am new in MVC. I am doing a program that edits existing records in a mongodb. My program is not updating the record.
This is the edit method:
[HttpPost]
public async Task<ActionResult> Edit(BioCardModel model)
{
await _bioCardServices.UpdateBioCard( model.cardId ,model);
return RedirectToAction("Index");
}
This is the method that updates the record in the 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 is a simple form that is populated with a record data.