private void View() { Console.Clear(); Console.Write("Event ID: "); int eventId = Convert.ToInt32(Console.ReadLine()); Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt"); Event events = eventsRepository.GetById(eventId); if (events == null) { Console.Clear(); Console.WriteLine("Event not found."); Console.ReadKey(true); return; } Console.WriteLine("ID:" + events.Id); Console.WriteLine("Username :"******"Password :"******"Start Date and Time :" + events.StartDateInput + " " + events.StartTimeInput); Console.WriteLine("End Date and Time :" + events.EndDateInput + " " + events.EndTimeInput); Console.ReadKey(true); }
public void AddEvent(string name, string location, string beginningDate, string endDate) { Repository.EventRepository repository = new Repository.EventRepository(); Entity.Event myEvent = new Entity.Event(); myEvent.name = name; myEvent.location = location; myEvent.beginningDate = beginningDate; myEvent.endDate = endDate; repository.Insert(myEvent); }
public void UpdateEvent(int id, string name, string location, string beginningDate, string endDate) { Repository.EventRepository repository = new Repository.EventRepository(); Entity.Event myEvent = new Entity.Event { id = id, name = name, location = location, beginningDate = beginningDate, endDate = endDate }; repository.Update(myEvent); }
public List <Entity.Event> MyGridView() { Repository.EventRepository repository = new Repository.EventRepository(); List <Entity.Event> data = repository.GetAllEvent(); //data.Columns.Add("id", "id"); //data.Columns.Add("Name", "Name"); //data.Columns.Add("Location", "Location"); //data.Columns.Add("Bdate", "Bdate"); //data.Columns.Add("EDate", "EDate"); return(data); }
private void GetAll() { Console.Clear(); Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt"); List <Event> events = eventsRepository.GetAll(); foreach (Event Event in events) { Console.WriteLine("ID:" + Event.Id); Console.WriteLine("Username :"******"Password :"******"Start Date and Time :" + Event.StartDateInput + " " + Event.StartTimeInput); Console.WriteLine("End Date and Time :" + Event.EndDateInput + " " + Event.EndTimeInput); Console.WriteLine("---------------------------------"); } Console.ReadKey(true); }
private void Add() { Console.Clear(); Event events = new Event(); Console.WriteLine("Add new Event:"); Console.Write("Name: "); events.Name = Console.ReadLine(); Console.Write("Location: "); events.Location = Console.ReadLine(); while (!ValidDate) { Console.Write("Please enter Start Date in format DD.MM.YYYY: "); events.StartDateInput = Console.ReadLine(); ValidDate = ValidateDate.ValidateData(events.StartDateInput); Console.Write("Please enter End Date in format DD.MM.YYYY: "); events.EndDateInput = Console.ReadLine(); ValidDate = ValidateDate.ValidateData(events.EndDateInput); } while (!ValidTime) { Console.Write("Please enter Start Time in format HH:mm:ss: "); events.StartTimeInput = Console.ReadLine(); ValidTime = ValidateTime.ValidatingTime(events.StartTimeInput); Console.Write("Please enter End Time in format HH:mm:ss: "); events.EndTimeInput = Console.ReadLine(); ValidTime = ValidateTime.ValidatingTime(events.EndTimeInput); } Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt"); eventsRepository.Save(events); Console.WriteLine("Event saved successfully."); Console.ReadKey(true); }
private void Delete() { Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt"); Console.Clear(); Console.WriteLine("Delete Event:"); Console.Write("Event Id: "); int eventId = Convert.ToInt32(Console.ReadLine()); Event events = eventsRepository.GetById(eventId); if (events == null) { Console.WriteLine("Event not found!"); } else { eventsRepository.Delete(events); Console.WriteLine("Event deleted successfully."); } Console.ReadKey(true); }
private void Update() { Console.Clear(); Console.Write("Event ID: "); int eventId = Convert.ToInt32(Console.ReadLine()); Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt"); Event events = eventsRepository.GetById(eventId); if (events == null) { Console.Clear(); Console.WriteLine("Event not found."); Console.ReadKey(true); return; } Console.WriteLine("Editing Event (" + events.Name + ")"); Console.WriteLine("ID:" + events.Id); Console.WriteLine("Name :" + events.Name); Console.Write("New Name:"); string name = Console.ReadLine(); Console.WriteLine("Location :" + events.Location); Console.Write("New Location:"); string location = Console.ReadLine(); Console.WriteLine("Start Date :" + events.StartDateInput); Console.Write("New Start Date in format DD.MM.YYYY: "); string startDate = Console.ReadLine(); ValidDate = ValidateDate.ValidateData(startDate); Console.WriteLine("End Date :" + events.EndDateInput); Console.Write("New End Date in format DD.MM.YYYY: "); string endDate = Console.ReadLine(); ValidDate = ValidateDate.ValidateData(endDate); Console.WriteLine("Start Time :" + events.StartTimeInput); Console.Write("New Start Time in format HH:mm:ss: "); string startTime = Console.ReadLine(); ValidTime = ValidateTime.ValidatingTime(startTime); Console.WriteLine("End Time :" + events.EndTimeInput); Console.Write("New End Time in format HH:mm:ss: "); string endTime = Console.ReadLine(); ValidTime = ValidateTime.ValidatingTime(endTime); if (!string.IsNullOrEmpty(name)) { events.Name = name; } if (!string.IsNullOrEmpty(location)) { events.Location = location; } if (!string.IsNullOrEmpty(startDate)) { events.StartDateInput = startDate; } if (!string.IsNullOrEmpty(endDate)) { events.EndDateInput = endDate; } if (!string.IsNullOrEmpty(startTime)) { events.StartTimeInput = startTime; } if (!string.IsNullOrEmpty(endTime)) { events.EndTimeInput = endTime; } eventsRepository.Save(events); Console.WriteLine("Event saved successfully."); Console.ReadKey(true); }
public void DeleteEvent(int id) { Repository.EventRepository repository = new Repository.EventRepository(); repository.Delete(id); }