public async Task<IHttpActionResult> Put(RecordModel record) { if (await RecordModel.Update(record)) { return Ok(); } else { return BadRequest(); } }
public static async Task<Boolean> Update(RecordModel model) { try { var db = new MongoClient(ConfigurationManager.AppSettings["Mongo"]).GetDatabase("interview").GetCollection<RecordModel>("records_miker"); await db.ReplaceOneAsync(m => m.Id == model.Id, model); } catch { return false; } return true; }
public IHttpActionResult Get(int id) { try { RecordModel r = new RecordModel().FindById(id); if (r == null) { return NotFound(); } else { return Ok(r); } } catch (Exception ex) { return BadRequest(ex.Message); } }