public async Task<ActionResult> EditAgent(User user) { var filter = Builders<BsonDocument>.Filter.Eq("Username", user.Username); var update = Builders<BsonDocument>.Update .Set("Password", user.Password) .Set("Name", user.Name) .Set("Lastname", user.Lastname) .Set("Role", user.Role) .CurrentDate("lastModified"); var result = await usersCollection.UpdateOneAsync(filter, update); Response.StatusCode = (int)HttpStatusCode.OK; return Json(result, JsonRequestBehavior.AllowGet); }
public async Task<ActionResult> CreateAgent(User user) { await usersCollection.InsertOneAsync(user.ToBsonDocument()); Response.StatusCode = (int)HttpStatusCode.Created; return Json(new { Message = "Usuario registrado." }, JsonRequestBehavior.AllowGet); }