static void Main(string[] args) { var course1 = new Courses() { Name = "C# dla poczatkujacych", Price = 2500, StartTime = DateTime.Parse("01.07.2017 15:00:00"), EndTime = DateTime.Parse("01.07.2017 17:00:00"), Places = 30 }; var course2 = new Courses() { Name = "C# dla zaawansowanych", Price = 4500, StartTime = DateTime.Parse("01.07.2017 17:00:00"), EndTime = DateTime.Parse("01.07.2017 19:00:00"), Places = 15 }; var course3 = new Courses() { Name = "JS dla poczatkujacych", Price = 2800, StartTime = DateTime.Parse("01.07.2017 16:00:00"), EndTime = DateTime.Parse("01.07.2017 18:00:00"), Places = 20 }; using (var courseDB = new WorkshopEntity()) { //var courseToDelete = courseDB.Courses.Where(c => c.Name != null); //foreach (var course in courseToDelete) //{ // courseDB.Courses.Remove(course); //} //courseDB.Courses.Add(course1); //courseDB.Courses.Add(course2); //courseDB.Courses.Add(course3); //courseDB.SaveChanges(); while (true) { Console.Clear(); var menu = new ShowMenu(); menu.MenuDrowing(); var select = Console.ReadLine(); if (select == "4") { break; } menu.Swich(select, courseDB); } } }
public async Task <ServiceResult> DeleteAsync(int id) { WorkshopEntity workshopEntity = await UnitOfWork.Workshops.GetOneAsync(id); if (workshopEntity == null) { return(NotFound()); } await UnitOfWork.Workshops.RemoveAsync(workshopEntity); return(await CommitAsync()); }
public void Swich(string select, WorkshopEntity courseDB) { switch (select) { case "1": { Console.Clear(); var allCourses = courseDB.Courses.Where(c => c.Name != null); Console.WriteLine($"Id kursu Nazwa kursu Poczatek kursu Koniec kursu Wolne miejsca Cena"); foreach (var course in allCourses) { Console.WriteLine($"{course.Id} {course.Name} {course.StartTime} {course.EndTime} {course.Places} {course.Price}"); } Console.WriteLine("Chcesz zapisac sie na kurs? [Y/N]?"); if (Console.ReadLine().ToLower() == "y") { Console.WriteLine("Podaj imie:"); var uName = Console.ReadLine(); Console.WriteLine("Podaj nazwisko:"); var uSername = Console.ReadLine(); Console.WriteLine("Podaj emial:"); var uEmail = Console.ReadLine(); var user = new UserObject(uName, uSername, uEmail); var userService = new UserService(courseDB); if (!userService.IfExist(user.Email)) { userService.AddUser(user); } userService.AddCourse(userService.ShowId(user.Email)); } break; } case "2": { var userService = new UserService(courseDB); userService.ShowUsers(); Console.WriteLine("Wybieram uzytkownika o ID"); var selectedUser = int.Parse(Console.ReadLine()); userService.ShowUserCourses(selectedUser); Console.ReadKey(); break; } } }
public FeeService() { this.courseDB = courseDB; }
public UserService(WorkshopEntity courseDB) { this.courseDB = courseDB; }