public async Task <ActorDomainModel> AddActor(ActorDomainModel actorModel) { // get all actors var actors = await _actorsRepository.GetAllAsync(); // check if there is actor with same first name and last name foreach (var actor in actors) { if (actor.FirstName == actorModel.FirstName && actor.LastName == actorModel.LastName) { return(null); } } Actor actorToAdd = new Actor { FirstName = actorModel.FirstName, LastName = actorModel.LastName }; var addedActor = _actorsRepository.Insert(actorToAdd); _actorsRepository.Save(); ActorDomainModel actorDomainModel = new ActorDomainModel { Id = addedActor.Id, FirstName = addedActor.FirstName, LastName = addedActor.LastName }; return(actorDomainModel); }