Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        public IActionResult GetNew()
        {
            var gData = new FeeDefinition();

            return(Ok(gData));
        }