public static void AddCompitoToGUI(Compito compito) { GUI gui = ApplicationSettings.Gui; if (gui != null) { //new[] = get the array type autonomously var row = new ListViewItem(new[] { compito.Autore.ToString(), compito.Materia, compito.Descrizione.ToString(), compito.Data.ToString() }); gui.listView1.Items.Add(row); } else { throw new NullReferenceException("First you have to start the GUI"); } }
public static List <Compito> GetCompiti() { try { JArray compiti = JArray.Parse(GetCompitiJson()); Console.WriteLine(compiti.ToString()); Compito[] tasks = new Compito[compiti.Count]; for (int i = 0; i < compiti.Count; i++) { string autore = compiti[i]["1"].ToString(); string materia = compiti[i]["2"].ToString(); string descrizione = compiti[i]["3"].ToString(); string data = compiti[i]["4"].ToString(); //locale information CultureInfo provider = CultureInfo.InvariantCulture; //the new format string format = "yyyy-MM-dd HH:mm:ss"; DateTime parsedData = DateTime.ParseExact(data, format, provider); tasks[i] = new Compito(autore, materia, descrizione, parsedData); } return(tasks.ToList()); } catch (Exception.ProcessInterruptedException es) { GUI gui = ApplicationSettings.Gui; if (gui != null) { GUIHelper.NotifyUser(gui, ApplicationSettings.NotifyTimeout, "ProcessInterruptedException", es.Message, ToolTipIcon.Warning); } else { Console.WriteLine(gui); MessageBox.Show(es.Message, "ProcessInterruptedException"); } return(new List <Compito>()); } }
public CompitoGUI(Compito compito) { InitializeComponent(); MaterialSkinManager materialSkinManager = MaterialSkinManager.Instance; materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; materialSkinManager.ColorScheme = new ColorScheme(Primary.Blue400, Primary.Blue500, Primary.Blue500, Accent.LightBlue200, TextShade.WHITE); materialSingleLineTextFieldAuthor.Text = compito.Autore; materialSingleLineTextFieldDataConsegna.Text = compito.Data.ToString(); materialSingleLineTextFieldDescription.Text = compito.Descrizione; materialSingleLineTextFieldMateria.Text = compito.Materia; Data = compito; timer = new System.Timers.Timer(); }
public async Task <IActionResult> Create(IFormCollection collection) { try { // TODO: Add insert logic here foreach (string userId in collection["utenti"]) { Compito compito = new Compito(); compito.UtenteId = userId; compito.GruppoId = collection["gruppo"]; _context.Add(compito); } await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } catch { return(RedirectToAction("Create")); } }