public async Task <(bool isSuccess, int id)> InsertAsync(InsertGenderViewModel entity) { var value = await _context.Genders.AddAsync(_mapper.Map <Gender>(entity)); var result = await _context.SaveChangesAsync().ToBooleanAsync(); return(result, value.Entity.Id); }
public async Task <IActionResult> InsertGender([FromBody] InsertGenderViewModel model, ApiVersion apiVersion) { var(isSuccess, id) = await _service.InsertAsync(model); if (isSuccess) { return(CreatedAtAction(nameof(GetGender), new { id, version = apiVersion.ToString() }, id)); } else { return(BadRequest()); } }