public async Task<string> PostActor (Actor actor) { actor.actorId = ObjectId.GenerateNewId().ToString(); var collection = database.GetCollection<Actor>("actors"); await collection.InsertOneAsync(actor); return actor.actorId; }
public async Task<string> PutActor (Actor actor) { var collection = database.GetCollection<Actor>("actors"); var filter = Builders<Actor>.Filter.Eq(s => s.actorId, actor.actorId); var update = Builders<Actor>.Update .Set ("actorId", actor.actorId) .Set ("name", actor.name) .Set ("country", actor.country) .Set ("imdbLink", actor.imdbLink) .Set ("birthDate", actor.birthDate); var result = await collection.UpdateOneAsync(filter, update); return result.ToString(); }