/// <summary> /// Tries to create a new cap through the Form Data. /// </summary> public void TryCreateCap() { if (ValidateFormData()) { BeerCapModel newCap = new BeerCapModel ( userCollection.Count + 1, SelectedBrand, SelectedQuality, SelectedAquireDate, CreatedUnderMessage ); userCollection.Add(newCap); userCollection.SaveCapCollectionToFile(user); BackToDataTable(); } }
/// <summary> /// Gets a saved Beer Cap Collection based on the User. /// </summary> /// <param name="collectionOwner"> /// The owner of the Beer Cap collection. /// </param> /// <returns> /// The User's Beer Cap collection. /// </returns> public static List <BeerCapModel> GetSavedBeerCapCollection(this UserModel collectionOwner) { List <BeerCapModel> loadedCaps = new List <BeerCapModel>(); List <string> lines = collectionOwner.CapCollectonFileName().FullUtilitiesPath().LoadFile(); foreach (string line in lines) { string[] props = line.Split(','); BeerCapModel capFromString = new BeerCapModel( int.Parse(props[0]), //ID int.Parse(props[1]).GetBrandFromIndex(), //Brand (Quality)int.Parse(props[2]), //Quality DateTime.Parse(props[3]), //Date Acquired props[4] //Under Cap Message ); loadedCaps.Add(capFromString); } return(loadedCaps); }