private static void Add() { //get the existing list of stuffs _stuffList = _stuffOps.GetAll(); //instantiate the new stuff object Stuffs.Stuff stuff = new Stuffs.Stuff(); //prompt the user for the stuff name Console.WriteLine(); Console.Write("What is this stuff you're trying to add? What's it called? "); //read the input from the console as the stuff name stuff.Stuff_Name = Console.ReadLine(); //prompt the user for the location name Console.WriteLine(); Console.WriteLine(">:| ...That's nice..."); Console.WriteLine(); Console.Write("Where is that stuff at? "); //read the input from the console as the location name stuff.Location_Name = Console.ReadLine(); //get the current date and time for Location_Date stuff.Location_Date = DateTime.Now; //call the stuff delta and add the stuff stuff = _stuffOps.Add(stuff, _stuffList); //give the user a confirmation--pause for a few seconds Console.WriteLine(); Console.WriteLine("Good to know...good to know..."); Console.WriteLine(); Console.WriteLine($"Got it! Added new stuff ID: {stuff.Stuff_ID}"); System.Threading.Thread.Sleep(3000); }
public List <Stuffs.Stuff> Delete(Stuffs.Stuff stuff, List <Stuffs.Stuff> stuffs) { try { stuffs.Remove(stuff); Save(stuffs); } catch (Exception ex) { ex.Data.Add("DeletionError", $"An error occurred while trying to delete some stuff. (Stuff ID: {stuff.Stuff_ID}"); throw; } return(stuffs); }
public Stuffs.Stuff Add(Stuffs.Stuff stuff, List <Stuffs.Stuff> stuffs) { //get the next stuff_id int newStuff_ID = GetNextId(stuffs); //assign the stuff an id stuff.Stuff_ID = newStuff_ID; //add the stuff to the list stuffs.Add(stuff); //save the list Save(stuffs); //return the stuff with the new ID return(stuff); }