public async Task<AddCharacterResponse> Add(AddCharacterRequest request) { var characterType = await _db.CharacterTypes.FindAsync(request.CharacterTypeId); var character = new Character { Name = request.Name, NumberOfComics = request.NumberOfComics, NumberOfSeries = request.NumberOfSeries, ProfilePage = request.ProfilePage, CharacterType = characterType }; _db.Characters.Add(character); await _db.SaveChangesAsync(); return new AddCharacterResponse { Success = true, Character = new CharacterDto {Id = character.Id} }; }
public async Task<IHttpActionResult> Post(AddCharacterRequest request) { var response = await _characterCommandService.Add(request); return CreatedAtRoute("DefaultApi", new { id = response.Character.Id }, response.Character); }