public async Task <CoinViewModel> AddAsync(CoinCreateModel cm) { var max = await base.MaxAsync(x => new CoinViewModel { Id = x.Id }); cm.Id = (short)(max == null? 1:++max.Id); return(await base.AddAsync <CoinCreateModel, CoinViewModel>(cm)); }
public async Task <IActionResult> Post([FromBody] CoinCreateModel cm) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var vm = await this.service.AddAsync(cm); return(Ok(vm)); }