Exemplo n.º 1
0
        private static void CreateCourse()
        {
            Console.WriteLine("*********  Create course  *********");
            int courseId = UI.Menu.ReadNumber("Course Id: ");

            Console.WriteLine("Course name: ");
            string courseName = Console.ReadLine();

            try
            {
                courseLogic.AddCourse(courseId, courseName);
                logs.SendTimestamp("CreateCourse", "admin", "Course created: " + courseName);
                Console.WriteLine("Course created correctly");
            }
            catch (CourseException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Try again please.");
                CreateCourse();
            }
        }
Exemplo n.º 2
0
        public IActionResult AddCourse(Course course)
        {
            if (ModelState.IsValid)
            {
                Course course1 = _courseLogic.AddCourse(course);
                if (course1 != null)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Error", "Error in adding Course");
                    return(View());
                }
            }
            else
            {
                ModelState.AddModelError("Error", "Validation Error");

                return(View());
            }
        }