private static void Delete()
{
Console.WriteLine("Plase Enter the Following Details");
int id;
User user = new User();
Console.WriteLine("\nEnter The Username ID:");
id = Convert.ToInt32(Console.ReadLine());
user.Id = id;
User ua = SetinfromationDelete(id);
DeleteUserRecord(user);
Console.WriteLine("\n The Username is Deleted:");
Console.ReadLine();
}
public static void DeleteUserRecord(User ca)
{
using (ModelContainer user_entity = new ModelContainer())
{
User cashir = user_entity.Users.Where(x => x.Id== ca.Id).Select(x => x).FirstOrDefault();
user_entity.Users.Remove(cashir);
user_entity.SaveChanges();
}
}
Save the changes and run the code .
No comments:
Post a Comment