Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }