public async Task <IActionResult> Post([FromBody] FeeDefinition feeDefinition) { if (!ModelState.IsValid) { return(BadRequest()); } var objId = await _feeDefinitionRepository.AddOrUpdateAsync(feeDefinition); if (objId == ObjectId.Empty) { return(NoContent()); } return(Ok(objId)); }
public async Task <ObjectId> AddOrUpdateAsync(FeeDefinition feeDefinition) { var upOpt = new UpdateOptions { IsUpsert = true }; var filter = Builders <FeeDefinition> .Filter.Eq("_id", feeDefinition._id); var replaceResult = await Collection().ReplaceOneAsync(filter, feeDefinition, upOpt); if (replaceResult.IsAcknowledged) { return((ObjectId)replaceResult.UpsertedId); } return(ObjectId.Empty); }
public IActionResult GetNew() { var gData = new FeeDefinition(); return(Ok(gData)); }