public IActionResult Index() { var context = new BookContext(); var allMembers = context.Members.ToList(); //this is a List of members var displayedMembers = new ListOfMembers { MemberList = allMembers }; return(View(displayedMembers)); // using (var context = new BookContext()) // { // context.Members.Add(member2); // context.SaveChanges(); // } return(View()); }
static void Main(string[] args) { FileSystem saveCash = new FileSystem("MEMBERCASH.TSHPANDA", "TheDirectory"); string JsonFromCash = saveCash.TextFromFile(); List <ClassToCash> ListOfMembers; if (string.IsNullOrEmpty(JsonFromCash)) { ListOfMembers = new List <ClassToCash>(); } else { //add commit 1 ListOfMembers = JsonConvert.DeserializeObject <List <ClassToCash> >(JsonFromCash); } Console.Write($"Tedad afrade mojood {ListOfMembers.Count} Mibashad EzafeKardane nafare jadid \"y\""); string flag = Console.ReadLine().ToLower(); if (flag == "y") { Console.Write("Chand nafar Register Beshavand ? "); int Tedad = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < Tedad; i++) { ClassToCash cash = new ClassToCash(); cash.id = i; Console.Write("Name Of Member : "); cash.Name = Console.ReadLine(); ListOfMembers.Add(cash); } } Console.WriteLine("Members ====> "); for (int i = 0; i < ListOfMembers.Count; i++) { Console.WriteLine($"id : {ListOfMembers[i].id} AND Name : {ListOfMembers[i].Name}"); } int iii = SaveCash(ListOfMembers); switch (iii) { case 1: Console.WriteLine("Cash Saved Done!"); break; case -1: Console.WriteLine("Failed !"); break; case -2: Console.WriteLine("Failed !"); break; default: Console.WriteLine("Nothing!"); break; } Console.ReadLine(); //taaaaaaaaaaaaghir2 }