public async Task <ExtendedActorDTO> AddActor(ExtendedActorDTO actor) { Actor newActor = _mapper.Map <Actor>(actor); await _actorRepository.AddActor(newActor); return(actor); }
public async Task <ActionResult <ExtendedActorDTO> > AddActor(ExtendedActorDTO actor) { try { return(new OkObjectResult(await _movieService.AddActor(actor))); } catch { return(new StatusCodeResult(500)); } }
public async Task Add_Actor() { var actor = new ExtendedActorDTO() { IMDBActorId = "nm0001618", Name = "Joaquin Phoenix", Born = new DateTime(1974, 10, 28) }; string json = JsonConvert.SerializeObject(actor); var response = await Client.PostAsync("/api/actors", new StringContent(json, Encoding.UTF8, "application/json")); response.StatusCode.Should().Be(HttpStatusCode.OK); var createdActor = JsonConvert.DeserializeObject <ExtendedActorDTO>(await response.Content.ReadAsStringAsync()); Assert.NotNull(createdActor); }