private static void InsertOrUpdate(User user, Service s) { try { _adminMgm.InsertOrUpdate(s); _adminMgm.InsertOrUpdate(user); Console.WriteLine("Service " + s.Name + " of " + s.Provider.Name + " Updated"); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void FillTokens() { try { Console.WriteLine("INSERT FILE NAME OR BLANK FOR DEFAULT"); string insertfile = Console.ReadLine(); if (string.IsNullOrWhiteSpace(insertfile)) { insertfile = "Tokens"; } List <Token> gotTokens = CommonLib.FromXml <List <Token> >("xml", insertfile); try { foreach (Token t in gotTokens) { _adminMgm.InsertOrUpdate(t); } Console.WriteLine("TOKENS UPDATED"); } catch (Exception ex) { Console.WriteLine("ERROR UPDATING TOKEN DATA (" + ex.Message + ")"); } } catch (Exception e) { Console.WriteLine("NOT VALID TOKENS FOUND ON FILE (" + e.Message + ")"); } }
private void ButtonValidarUser_Click(object sender, RoutedEventArgs e) { if (action == Actions.BORRAR) { BorraToken(); } if (!ValidFrom()) { return; } Token u = new Token(); u.Name = Txt_Name.Text; u.Hours = int.Parse(Txt_Horas.Text); if (AdminMgm.InsertOrUpdate(u)) { MessageBox.Show("Token Registrado!"); } else { MessageBox.Show("Error en la inserción del Token"); } }
private static void InsertOrUpdate(Token token) { AdminManagement _adminMgm = AdminManagement.GetInstance(); if (_adminMgm.InsertOrUpdate(token)) { Console.WriteLine("Token " + token.ID + " : " + token.Name + " Insert"); } }
private void Btn_nuevaCat_Click(object sender, RoutedEventArgs e) { if (!ValidateEntranceCat()) { return; } var existst = admin.GetCategory(Txt_NombreCat.Text); if (existst != null) { MessageBox.Show("Categoría duplicada"); return; } admin.InsertOrUpdate(new Category { Name = Txt_NombreCat.Text }); ShowCategories(); }
private void Btn_Ofertar_Copy_Click(object sender, RoutedEventArgs e) { try { ValidForm(); } catch (Exception ex) { MessageBox.Show("No se ha guardado el servicio. " + ex.Message); return; } List <Token> precio = SetPrice(int.Parse(Txt_Precio.Text)); try { AdminMgm.InsertOrUpdate(new Service { Name = Txt_NombreServicio.Text, Description = Txt_DescServicio.Text, Price = precio, Available = true, Category = (Category)Cb_Categorias.SelectedItem, Provider = UserManagement.GetInstance().CurrentUser, DateIni = (DateTime)DatipiIni.SelectedDate, DateEnd = (DateTime)DatipiEnd.SelectedDate, }); MessageBox.Show("Servicio Guardado con Éxito"); LimpiaForm(); } catch (Exception ex) { MessageBox.Show("No se ha guardado el servicio. Inténtalo más tarde" + "\n \n " + ex.Message); } }