static string GetVideoNameFromInput(CrudOptionsTypes option, string currentName = "") { Console.WriteLine("Introdueix el nom del video o 'sortir' per sortir"); var text = Console.ReadLine(); var optionName = CrudOptionsNames[option]; while (true) { if (text == "sortir") { return(null); } if (!Video.ValidateNameFormat(text)) { Console.WriteLine(Video.NameFormatError); Console.WriteLine("Introdueix el nom del video o 'sortir' per sortir"); } else if (!Video.ValidateVideoNameDuplicated(text, currentName) && (optionName != CrudOptionsNames[CrudOptionsTypes.DeleteOrView])) { Console.WriteLine($"{Video.ValidateVideoNameDuplicated(text,currentName)} {text}"); Console.WriteLine("Introdueix el nom del video o 'sortir' per sortir"); } else { return(text); } text = Console.ReadLine(); } }
static string GetCrudOptionForVideoName(CrudOptionsTypes option, string input, out string textOption) { textOption = string.Empty; var optionName = CrudOptionsNames[option]; if (string.IsNullOrEmpty(input)) { return(null); } if (input.StartsWith(optionName)) { char[] c1 = { ' ' }; var spaso = input.Split(c1); if (spaso.Length > 2) { Console.WriteLine("warning: there more parameters than needed after subject name"); } else if (spaso.Length > 1) { var text = spaso[1]; var currentVideoName = Video.IsVideoNameValid(text) ? text : string.Empty; while (true) { if (!string.IsNullOrEmpty(currentVideoName)) { textOption = optionName; return(currentVideoName); } Console.WriteLine($"El video {spaso[1]} no existeix o té un format incorrecte, torna a escriure-la o 'sortir' per sortir"); text = Console.ReadLine(); if (text == "sortir") { ShowUsersMenuOptions(); return(null); } currentVideoName = Video.IsVideoNameValid(text) ? text : string.Empty; } } } return(null); }