private MaterialDTO BasicInfoInput() { string name = string.Empty; string link = string.Empty; string skills = string.Empty; name = InfoUnit.GetInfoUnit(name, x => !string.IsNullOrEmpty(x.ToString()) && x.ToString().Length > 1, "Enter material name", @"Error! Enter the material name!").ToString(); link = InfoUnit.GetInfoUnit(link, x => !string.IsNullOrEmpty(x.ToString()) && Regex.IsMatch(x.ToString(), urlRegex, RegexOptions.IgnoreCase), "Enter material link!", @"Error! Enter the correct link!").ToString(); skillService.ShowSkills(); List <Skill> skillList = new List <Skill>(); while (true) { string command = string.Empty; command = InfoUnit.GetInfoUnit(command, x => !string.IsNullOrEmpty(x.ToString()) && new List <string> { "0", "1", "2" }.Contains(x.ToString()), "Wanna add new skill(1) or existing one(2) PRESS 0 TO EXIT SKILL ADDING MODE?", @"Error! Enter the correct command!").ToString(); if (command == "0") { break; } if (command == "1") { var skillName = skillInputService.SkillInfoInput(); var skill = skillService.Get(skillName); skillList.Add(skill); } else { string skillName = string.Empty; skillName = InfoUnit.GetInfoUnit(skillName, x => !string.IsNullOrEmpty(x.ToString()) && x.ToString().Length > 1, "Enter skill name", @"Error! skill name invalid!").ToString(); skillList.Add(skillService.Get(skillName.TrimStart())); } } return(new MaterialDTO(name, link, skillList)); }
internal void Functionality() { IRepository <User> userRepository = new UserRepository(context); var interactionCommands = new InteractionCommands(); this.MenuInfo(); while (true) { Console.WriteLine("Select a number and press enter!"); var command = Console.ReadLine(); if (command == "0") { break; } switch (command) { case "1": registrationService.Register(); break; case "2": if (!session.IsAuthorised) { authorizationService.SignIn(userRepository); } else { Console.WriteLine("Already authorised"); } break; case "3": if (session.IsAuthorised) { authorizationService.SignOut(); } else { Console.WriteLine("Already unauthorised"); } break; case "4": Console.WriteLine(session.IsAuthorised ? "Yes" : "No"); break; case "5": interactionCommands.Show(userRepository); break; case "6": Console.WriteLine("Enter the email you want to delete."); interactionCommands.Delete(userRepository); break; case "7": Console.Clear(); MenuInfo(); break; case "8": materialInputService.MaterialInfoInput(); break; case "9": materialService.ShowMaterials(); break; case "10": courseInputService.CourseinfoInput(); break; //case "11": // var courses = courseService.GetCourses(); // if (!courses.Any()) // { // Console.WriteLine("no courses found"); // } // else // { // foreach (var course in courses) // { // Console.WriteLine(course); // } // } // break; case "12": courseInputService.CourseInfoUpdate(); break; case "13": skillInputService.SkillInfoInput(); break; case "14": userInfoInputService.PrintSessionUser(); break; case "15": courseInputService.StartCourse(); break; case "16": if (session.IsAuthorised) { courseService.GetStartedCourses(session.User.Email).ForEach(c => Console.WriteLine(c)); } else { Console.WriteLine("You need to authorise"); } break; case "17": if (session.IsAuthorised) { courseInputService.CompleteCourse(); } else { Console.WriteLine("You need to authorise"); } break; case "18": if (session.IsAuthorised) { courseService.GetCompletedCourses(session.User.Email).ForEach(c => Console.WriteLine(c)); } else { Console.WriteLine("You need to authorise"); } break; default: Console.WriteLine("Command not found!"); break; } } }