public static ActedInFilmEntity MapToEntity(ActedInFilmDetailModel model, IEntityFactory entityFactory) { var entity = (entityFactory ??= new EntityFactory()).Create <ActedInFilmEntity>(model.Id); entity.Id = model.Id; entity.ActorId = model.ActorId; entity.Actor = (entityFactory ??= new EntityFactory()).Create <PersonEntity>(model.ActorId); entity.FilmId = model.FilmId; entity.Film = (entityFactory ??= new EntityFactory()).Create <FilmEntity>(model.FilmId); return(entity); }
private void Delete() { var actor = _personRepository.GetById(ActorId); Model = new ActedInFilmDetailModel(); Model = actor.ActedInFilms.Single(film => film.FilmId == DeleteFilmId); var delete = _messageDialogService.Show( $"Delete", $"Do you want to delete film {Model?.OriginalName} from actor {Model.FirstName} {Model.LastName}?", MessageDialogButtonConfiguration.YesNo, MessageDialogResult.No); if (delete == MessageDialogResult.No) { return; } try { _actedInFilmRepository.Delete(Model.Id); } catch { var _ = _messageDialogService.Show( $"Deleting of film {Model?.OriginalName} from actor {Model.FirstName} {Model.LastName} failed!", "Deleting failed", MessageDialogButtonConfiguration.OK, MessageDialogResult.OK); return; } _mediator.Send(new UpdateMessage <FilmWrapper> { Model = _filmRepository.GetById(DeleteFilmId) }); _mediator.Send(new UpdateMessage <PersonWrapper> { Model = actor }); }
private void Add() { var actor = _personRepository.GetById(ActorId); var film = _filmRepository.GetById(AddFilmId); Model = new ActedInFilmDetailModel() { ActorId = ActorId, FirstName = actor.FirstName, LastName = actor.LastName, FilmId = AddFilmId, OriginalName = film.OriginalName }; Model = _actedInFilmRepository.InsertOrUpdate(Model); _mediator.Send(new UpdateMessage <FilmWrapper> { Model = film }); _mediator.Send(new UpdateMessage <PersonWrapper> { Model = actor }); }