public ColoringBookPageDialog(ColoringBookPage item, bool isEdit, IList <ArtSupplyVM> artSupplies) { InitializeComponent(); if (item == null) { throw new ArgumentNullException(nameof(item)); } if (artSupplies == null) { throw new ArgumentNullException(nameof(artSupplies)); } Item = item; if (isEdit) { Text = "Edit Page"; } else { Text = "Add new page"; } _artSuppliesIds = new List <int>(artSupplies.Count); foreach (var artSupply in artSupplies) { coloringBookDetailDialogArtSuplliesClb.Items.Add($"{artSupply.Name} ({artSupply.Brand})"); _artSuppliesIds.Add(artSupply.ID); } }
public ColoringBookPage GetForAdd(int coloringBookId) { var coloringBookPage = new ColoringBookPage(); coloringBookPage.BookID = coloringBookId; coloringBookPage.PageNumber = getNewPageNbr(coloringBookId); return(coloringBookPage); }
public void Add(ColoringBookPage coloringBookPage) { if (coloringBookPage == null) { throw new ArgumentNullException(nameof(coloringBookPage)); } var items = readFromFile(); coloringBookPage.ID = getNewId(items); items.Add(coloringBookPage); saveToFile(items); }
public void Edit(ColoringBookPage coloringBookPage) { var items = readFromFile(); var item = getItemById(items, coloringBookPage.ID); if (item != null) { item.PageNumber = coloringBookPage.PageNumber; item.PageDescription = coloringBookPage.PageDescription; item.Note = coloringBookPage.Note; item.StartDate = coloringBookPage.StartDate; item.FinishDate = coloringBookPage.FinishDate; item.ArtSuppliesUsed = coloringBookPage.ArtSuppliesUsed; saveToFile(items); } }