public void UpdateByIDAction() { Console.Write("Press any key to show all data: "); string name = Console.ReadLine(); Console.Write("Enter the updateable Product ID: "); long ID = long.Parse(Console.ReadLine()); var Data = repo.Get(ID); Console.WriteLine($"{Data.ProductID} {Data.ProductName} {Data.Price} {Data.Quantity} {Data.Buyer}"); this.ShowAllDataAction(); Console.Write("\nDo you want to update "); Console.Write("\nPress any key to update...\n"); this.WaitForGoBack(); Product obj2 = new Product(); ConColor obj = new ConColor(); obj.WriteMessage("Enter a valid ID: ", MessageType.Warning); obj2.ProductID = long.Parse(Console.ReadLine()); obj.WriteMessage("\nEnter your Product Name: ", MessageType.Warning); obj2.ProductName = Console.ReadLine(); obj.WriteMessage("Enter the Product Price: ", MessageType.Warning); obj2.Price = int.Parse(Console.ReadLine()); obj.WriteMessage("Enter the Product Quantity: ", MessageType.Warning); obj2.Quantity = int.Parse(Console.ReadLine()); obj.WriteMessage("\nEnter your Buyer: ", MessageType.Warning); obj2.Buyer = Console.ReadLine(); repo.Update(obj2); obj.WriteMessage("\nThe Product is Succesfully Updated.", MessageType.Success); }
private static void WriteLine(string value, ConsoleColor background, ConsoleColor foreground) { using (var conColor = new ConColor(background, foreground)) Console.Out.WriteLine($"[{DateTime.Now}]{value}"); }