void Register() { using (var toyapp = new ToyContext()) { Console.Write("\nCustomer Name :-"); var name = Console.ReadLine(); Console.WriteLine("\nEnter Email :-"); var email = Console.ReadLine(); Console.WriteLine("\nEnter Mobile Number."); var mobile = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nEnter Password."); var password = Console.ReadLine(); Customer customer = new Customer(name, email, mobile, password); try { toyapp.Costomers.Add(customer); toyapp.SaveChanges(); Console.WriteLine("\nAdded Successfully\n"); } catch (Exception e) { Console.WriteLine(e); } } }
void AddToy() { using (var toyapp = new ToyContext()) { Console.Write("\nEnter Toy Name : "); var toyName = Console.ReadLine(); Console.WriteLine("\nWrite Description :-"); var description = Console.ReadLine(); Console.WriteLine("\nEnter Price :-"); var price = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nEnter category id :-"); var catId = Convert.ToInt32(Console.ReadLine()); Toy toy = new Toy(toyName, description, price, catId); try { toyapp.Toys.Add(toy); toyapp.SaveChanges(); Console.WriteLine("\nAdded Successfully\n"); } catch (Exception e) { Console.WriteLine(e); } } }
void AddScheme() { using (var toyapp = new ToyContext()) { Console.Write("\nEnter Scheme Name :- "); var schemeName = Console.ReadLine(); Console.WriteLine("\nEnter Description :-"); var description = Console.ReadLine(); Console.WriteLine("\nEnter offeramount :- "); var offer = Convert.ToInt32(Console.ReadLine()); Scheme scheme = new Scheme(schemeName, description, offer); try { toyapp.Schemes.Add(scheme); toyapp.SaveChanges(); Console.WriteLine("\nAdded Successfully\n"); } catch (Exception e) { Console.WriteLine(e); } } }
public void AddCategory() { using (var toyapp = new ToyContext()) { string CategoryName; Console.WriteLine("\nEnter CategoryName :-"); CategoryName = Console.ReadLine(); var category = new Category { CategoryName = CategoryName, }; toyapp.Categories.Add(category); toyapp.SaveChanges(); Console.WriteLine("\nAdded Successfully\n"); } }