static void removeCompney() { using (var context = new Context()) { Admins ad = new Admins(); Console.WriteLine("Enter UserName"); ad.UserName = Console.ReadLine(); Console.WriteLine("Enter Password"); ad.Password = Console.ReadLine(); var check = context.Admins.SingleOrDefault(t => t.UserName == ad.UserName && t.Password == ad.Password); if (check != null) { try { Compneys hp = new Compneys(); Console.WriteLine("Enter Compneys Id"); hp.CompneyId = Convert.ToInt32(Console.ReadLine()); context.Compneys.Remove(hp); context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } else { Console.WriteLine("Incorrect UserName or Password"); } } }
static void getCompney() { using (var context = new Context()) { Compneys hp = new Compneys(); foreach (var item in context.Compneys.ToList()) { Console.WriteLine($"ID {item.CompneyId} Name {item.CompneyName} "); } } }