public async Task <IActionResult> Post([FromBody] List <FruitDto> fruitDtoList) { try { if (fruitDtoList == null) { return(this.BadRequestEx("fruitDtoList")); } await _fruitService.FruitAdd(fruitDtoList); return(this.CreatedEx()); } catch (Exception ex) { return(this.ErrorEx(ex.Message)); } }
public IActionResult Post([FromBody] FruitDto fruitDto) { try { if (fruitDto == null) { return(this.BadRequestEx("fruitDto")); } var fruitDtoBson = BsonDocument.Parse(JsonConvert.SerializeObject(fruitDto)); if (fruitDtoBson == null) { return(this.BadRequestEx("fruitDto")); } _fruitService.FruitAdd(fruitDtoBson); return(this.CreatedEx()); } catch (Exception ex) { return(this.ErrorEx(ex.Message)); } }