/// <summary> /// Command for add comic /// </summary> public void AddExecute() { if (_selectedAuthorsList.Count == 0 || String.IsNullOrEmpty(InputTitle) || (String.IsNullOrEmpty(SelectedViewPublisher.Name) || String.IsNullOrEmpty(SelectedViewSeries.Name))) { throw new PresentationException("Pls fill everything in."); } ViewComic comic = new ViewComic(InputTitle, SelectedViewSeries, _comic.SeriesNumber, new List <ViewAuthor>(_selectedAuthorsList), SelectedViewPublisher); controller.AddComic(Mapper.ViewComicMapper(comic)); }
/// <summary> /// Databinded Command to add comic to list of comics /// </summary> public void AddComicExecute() { if (SelectedComic == null) { throw new PresentationException("Gelieve een strip te selecteren."); } ViewComic comic = SelectedComic; int amount = OrderAmount; ComicList.Add(new KeyValuePair <ViewComic, int>(comic, amount)); }
public AddComicViewModel() { controller = new Controller(new UnitOfWork()); _comic = new ViewComic(); _seriesList = new ObservableCollection <ViewSeries>(Mapper.SeriesMapper(controller.GetSeries()).OrderBy(name => name)); _possibleAuthorsList = new ObservableCollection <ViewAuthor>(); _allAuthorsList = new List <ViewAuthor>(Mapper.AuthorMapper(controller.GetAuthors())); _possibleAuthorsList = new ObservableCollection <ViewAuthor>(_allAuthorsList); _selectedAuthorsList = new ObservableCollection <ViewAuthor>(); _publisherList = new ObservableCollection <ViewPublisher>(Mapper.PublisherMapper(controller.GetPublishers()).OrderBy(name => name)); _titelList = new ObservableCollection <string>(); CreateCommand(); }
/// <summary> /// sets ui values to the selectedcomic /// </summary> /// <param name="comic">comic to set</param> public void SetComic(ViewComic comic) { InputTitle = comic.Title; SelectedViewSeries = comic.Series; InputSeriesNr = comic.SeriesNumber.ToString(); foreach (ViewAuthor author in comic.Authors) { SelectedAuthorList.Add(author); PossibleAuthorsList.Remove(author); } SelectedViewPublisher = comic.Publisher; }
/// <summary> /// Constructor to set members from with viewcomic /// </summary> /// <param name="viewComic">viewcomic to map to gridrow</param> public GridRow(ViewComic viewComic) { this.Comic = viewComic; Title = Comic.Title; Series = Comic.Series.Name; SeriesNumber = Comic.SeriesNumber.ToString(); foreach (ViewAuthor author in viewComic.Authors) { Authors = Authors + author.Name + ", "; } Publishers = viewComic.Publisher.Name; }
/// <summary> /// Maps a viewcomic object to a comic object. So that it can be transfered to the domainLayer. /// </summary> /// <param name="viewcomic">viewcomic object</param> /// <returns>Comic object</returns> public static Comic ViewComicMapper(ViewComic viewcomic) { return(new Comic(viewcomic.Title, new Series(viewcomic.Series.Name), viewcomic.SeriesNumber, ViewAuthorMapper(viewcomic.Authors), new Publisher(viewcomic.Publisher.Name))); }