public async Task <IActionResult> Post(Models.MongoTest.MgExample example) { UnitOfWork.BeginTransaction(); await UnitOfWork.Use <IMgExampleRepo>().PostAsync(example); UnitOfWork.Commit(); return(NoContent()); }
public async Task <UpdateResult> PutAsync(Models.MongoTest.MgExample example) { var filter = Builders <Models.MongoTest.MgExample> .Filter.Eq(x => x.Id, example.Id); var update = Builders <Models.MongoTest.MgExample> .Update.Set(x => x.Name, example.Name) .Set(x => x.RowDatetime, example.RowDatetime) .Set(x => x.IsDelete, example.IsDelete); var result = await MongoCollection.UpdateOneAsync(filter, update, ClientSessionHandle); return(result); }
public async Task <ActionResult <DeleteResult> > PutAsync(string id, Models.MongoTest.MgExample example) { if (id != example.Id) { return(BadRequest()); } var entity = await UnitOfWork.Use <IMgExampleRepo>().GetAsync(id); if (entity == null) { return(NotFound()); } UnitOfWork.BeginTransaction(); var result = await UnitOfWork.Use <IMgExampleRepo>().PutAsync(example); UnitOfWork.Commit(); return(Ok(result)); }
public async Task PostAsync(Models.MongoTest.MgExample example) { await MongoCollection.InsertOneAsync(example, ClientSessionHandle); }