private async void LoadItems() { Student s1 = new Student(); s1.Name = "John"; s1.Surname = "Doe"; s1.Age = 15; s1.Mail = "*****@*****.**"; s1.Password = "******"; s1.Username = "******"; await student1.Insert(s1); Student s2 = new Student(); s2.Name = "Pierre"; s2.Surname = "Paul"; s2.Age = 21; s2.Mail = "*****@*****.**"; s2.Password = "******"; s2.Username = "******"; await student1.Insert(s2); var result = this.pageStudent.ucStudentUserControl.Student = await student1.Get(1); }
private async void MenuDuplicate_OnClick(object sender, RoutedEventArgs e) { if (this.employeeAdmin.ucEmployeeList.itemList.SelectedItems.Count > 0) { Employee dupplicateEmployee = new Employee(this.employeeAdmin.ucEmployeeList.itemList.SelectedItem as Employee); await employeeManager.Insert(dupplicateEmployee); InitLUC(); } }
private async void DuplicateStreetNumberContextMenu_OnClick(object sender, RoutedEventArgs e) { if (this.streetNumberAdmin.ucStreetNumberList.ItemsList.SelectedIndex > -1) { var streeNumber = new StreetNumber(); streeNumber = (StreetNumber)this.streetNumberAdmin.ucStreetNumberList.ItemsList.SelectedItem; await streetNumberManager.Insert(streeNumber); InitLists(); } }
private async void BtnValidate_Click(object sender, RoutedEventArgs e) { List <Role> userRoles = new List <Role>(); foreach (object childStackPanel in this.userManagerView.stackpanelRoles.Children) { if (childStackPanel is StackPanel) { foreach (object child in (childStackPanel as StackPanel).Children) { if (child is CheckBox) { if ((child as CheckBox).IsChecked == true) { Role role = roles.FirstOrDefault(x => x.Name == (child as CheckBox).Name.Replace("checkbox", "")); if (role != null) { userRoles.Add(role); } } } } } } this.userCreate.Roles = userRoles; await userManager.Insert(this.userCreate); MessageBox.Show("Data Inserted"); UserManagerViewModel viewModel = new UserManagerViewModel(); }
private void Ajout() { if (!this.structureAdmin.ucStructure.txtBSurface.Text.Contains("-")) { int test; bool isParsable = Int32.TryParse(this.structureAdmin.ucStructure.txtBSurface.Text, out test); if (isParsable) { if (test > 0) { structureManager.Insert(this.structureAdmin.ucStructure.Structure); structureAdmin.UCstructureList.Obs.Add(this.structureAdmin.ucStructure.Structure); this.structureAdmin.ucStructure.Structure = new Structure(); } else { System.Windows.MessageBox.Show("Surface doit être > à 0 ... biche"); } } else { System.Windows.MessageBox.Show("Veuillez n'entrer que des chiffres"); } } else { System.Windows.MessageBox.Show("Erreur surface négative wsh"); } }
private async void BtnValidate_Click(object sender, System.Windows.RoutedEventArgs e) { try { String json = this.dataInsertView.txtBoxJson.Text; json = json.Replace("\r\n", " "); json = json.Replace("\n", " "); json = json.Replace("\\", " "); JsonConvert.DeserializeObject <Object>(json); MySQLManager <User> userManager = new MySQLManager <User>(DataConnectionResource.LOCALMYSQL); User currentUser = await userManager.Get(LoggedUser.UserId); MySQLManager <Data> dataManager = new MySQLManager <Data>(DataConnectionResource.LOCALMYSQL); Data data = new Data(); data.JsonData = this.dataInsertView.txtBoxJson.Text; data.User = currentUser; await dataManager.Insert(data); MessageBox.Show("Data Inserted"); DataInsertViewModel viewModel = new DataInsertViewModel(currentUser); } catch (Exception ex) { this.dataInsertView.txtBoxJson.Text = ex.Message; } }
private async void BtnNewMap_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".png"; dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); if (result == true) { // Get the selected file name string filename = dlg.FileName; // Copy the file to local app directory string folderpath = System.IO.Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\Images\\"; if (!Directory.Exists(folderpath)) { Directory.CreateDirectory(folderpath); } string newPath = folderpath + System.IO.Path.GetFileName(filename); System.IO.File.Copy(filename, newPath, true); filename = newPath; // Open dialog to get a name for the file string name; DialogWindow inputDialog = new DialogWindow("Please enter a name for your map:", "new map"); if (inputDialog.ShowDialog() == true) { name = inputDialog.Answer; } else { name = "new map" + DateTime.Now.ToString(); } if (name == "new map") { name += DateTime.Now.ToString(); } // Save the new Map currentMap = new Map(); currentMap.FileName = filename; currentMap.Name = name; MySQLManager <Map> mapManager = new MySQLManager <Map>(); await mapManager.Insert(currentMap); this.mainAdmin.ListMapUC.AddItem(currentMap); } }
private async void ClickOK(object sender, RoutedEventArgs e) { if (this.animalAdmin.UCAnimal.Animal.Id != 0) { if (this.animalAdmin.UCAnimal.Animal.Weight > 0) { if (animalAdmin.UCAnimal.Animal.IsDead == true || animalAdmin.UCAnimal.Animal.IsDead == false) { await animalManager.Update(this.animalAdmin.UCAnimal.Animal); MessageBox.Show("You have update a animal"); } else { MessageBox.Show("Enter isDead : False or True"); } } else { MessageBox.Show("Enter weight > 0"); } } else { if (this.animalAdmin.UCAnimal.Animal.Weight > 0) { if (animalAdmin.UCAnimal.Animal.IsDead == true || animalAdmin.UCAnimal.Animal.IsDead == false) { await animalManager.Insert(this.animalAdmin.UCAnimal.Animal); MessageBox.Show("You have create a new animal"); } else { MessageBox.Show("Enter isDead : False or True"); } } else { MessageBox.Show("Enter weight > 0"); } } InitLists(); }
private async void btnAddJob_Click(object sender, RoutedEventArgs e) { if (this.checkValidity(this.jobAdmin.UCJob.Job)) { this.jobAdmin.UCJob.Job.Schedule = this.jobAdmin.UCJob.ucSchedule.Schedule; await jobManager.Insert(this.jobAdmin.UCJob.Job); InitLUC(); } }
public async Task <ActionResult> Create([Bind(Include = "Id,Firstname,Lastname")] User user) { if (ModelState.IsValid) { User tmpUser = user; tmpUser.AddressId = null; await manager.Insert(user); } return(RedirectToAction("Index")); }
private async void NormalGameGeneration(string CastleName) { MySQLFullDB mySQLFullDB = new MySQLFullDB(); mySQLFullDB.InitLocalMySQL(); Castle newCastle = new Castle() { Name = CastleName, Life = 100 }; await myCastleManager.Insert(newCastle); Castle enemyCastle = new Castle() { Name = "Méchant chato", Life = 100 }; await myCastleManager.Insert(enemyCastle); MainCastleView newPage = new MainCastleView(); Switcher.Switch(newPage); }
public async Task <ActionResult> Create(T item) { if (ModelState.IsValid) { await db.Insert(item); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
private void CMDuplicate_Click(object sender, RoutedEventArgs e) { Structure duplicatedStructure = new Structure(); Structure structureToDuplicate = new Structure(); structureToDuplicate = ItemsList.SelectedItem as Structure; duplicatedStructure.Id = 0; duplicatedStructure.Name = structureToDuplicate.Name; duplicatedStructure.Schedule = structureToDuplicate.Schedule; duplicatedStructure.Surface = structureToDuplicate.Surface; Obs.Add(duplicatedStructure); mySQLManager.Insert(duplicatedStructure); }
private async void BtnMettreAjour_Click(object sender, System.Windows.RoutedEventArgs e) { if (this.itemsAdminV.UCItems.Items.Id != 0) { await itemsManager.Update(this.itemsAdminV.UCItems.Items); } else { await itemsManager.Insert(this.itemsAdminV.UCItems.Items); this.itemsAdminV.UCItems.Items = currentItems; } }
private async void LoadItems() { MusicClass mc1 = new MusicClass(); mc1.ClassAge = 8; mc1.ClassExperience = 1; mc1.NumberUser = 10; await musicClass1.Insert(mc1); var result = this.pageSchool.ucMusicClassUserControl.MusicClass = await musicClass1.Get(1); this.pageSchool.ucMusicClassUserControl.MusicClass = result; }
private async void BtnValidateAddress_Click(object sender, System.Windows.RoutedEventArgs e) { //MySQLManager<StreetNumber> snManager = new MySQLManager<StreetNumber>(); if (currentAddress.Id != 0) { //await addressManager.Update(currentAddress); this.addressAdmin.NavigationService.GoBack(); } else { try { await addressManager.Insert(currentAddress); this.addressAdmin.UCAddressList.AddItem(currentAddress); this.addressAdmin.NavigationService.GoBack(); } catch (Exception) { MessageBox.Show("One or more fields are not valid."); } //await snManager.Insert(currentAddress.StreetNumber); } }
private async void MysqlTest() { MySQLManager <Class1> managerC1 = new MySQLManager <Class1>(DataConnectionResource.LOCALMYSQL); EntityGenerator <Class1> gen = new EntityGenerator <Class1>(); EntityGenerator <Class2> gen1 = new EntityGenerator <Class2>(); Class1 c1 = gen.GenerateItem(); c1.Addresses = gen1.GenerateListItems() as List <Class2>; await managerC1.Insert(c1); var result = await managerC1.Get() as List <Class1>; c1.Addresses.Add(gen1.GenerateItem()); await managerC1.Update(c1); var result1 = await managerC1.Get() as List <Class1>; }
private void CreateUserBtn_OnClick(object sender, RoutedEventArgs e) { User keen = new User(); keen.Firstname = this.userCreation.firstname.Text; keen.Lastname = this.userCreation.lastname.Text; keen.Login = keen.Firstname + keen.Lastname; keen.Password = this.userCreation.password.Text; //jason.Roles.Add(r1); keen.IdRole = 2; MessageBox.Show("Utilisateur créé"); MySQLManager <User> managerUser = new MySQLManager <User>(DataConnectionResource.LOCALMYSQL); managerUser.Insert(keen); }
private async void DuplicateNutritionContextMenu_OnClick(object sender, RoutedEventArgs e) { if (ItemsList.SelectedIndex > -1) { var schedule = new Schedule(); var scheduleTmp = new Schedule(); schedule = ItemsList.SelectedItem as Schedule; // casting the list view if (schedule.Id > 0 && schedule != null) { scheduleTmp.Start = schedule.Start; scheduleTmp.End = schedule.End; scheduleTmp.Id = 0; await scheduleManager.Insert(scheduleTmp); Obs.Add(scheduleTmp); MessageBox.Show("You are in duplicate schedule for:\nStart : " + scheduleTmp.Start + "\nEnd : " + scheduleTmp.End, "Duplicate", MessageBoxButton.OK, MessageBoxImage.Information); } } }
private async void BtnOk_Click(object sender, RoutedEventArgs e) { if (currentTheme.PawnFileName != null && currentTheme.RookFileName != null && currentTheme.KnightFileName != null && currentTheme.BishopFileName != null && currentTheme.QueenFileName != null && currentTheme.KingFileName != null) { currentTheme.Name = this.themeAdmin.txtBName.Text; if (currentTheme.Name.Length == 0) { currentTheme.Name = "new_theme_" + DateTime.Now.ToString(); } themeManager = new MySQLManager <Theme>(); await themeManager.Insert(currentTheme); this.themeAdmin.NavigationService.GoBack(); } else { System.Windows.Forms.MessageBox.Show("Your theme is not complete!", "Theme incomplete", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
private async void btnOk_Click(object sender, RoutedEventArgs e) { int difDate = 0; if (this.scheduleAdmin.scheduleUC.Schedule != null) { difDate = DateTime.Compare(this.scheduleAdmin.scheduleUC.Schedule.Start, this.scheduleAdmin.scheduleUC.Schedule.End); if (difDate > 0) { MessageBox.Show("Date of Start > Date of End", "Warning", MessageBoxButton.OK, MessageBoxImage.Information); } else if (this.scheduleAdmin.scheduleUC.Schedule.Id > 0) { await scheduleManager.Update(this.scheduleAdmin.scheduleUC.Schedule); } else { await scheduleManager.Insert(this.scheduleAdmin.scheduleUC.Schedule); AddInList(); } } }
private async void BtnMettreAjour_Click(object sender, System.Windows.RoutedEventArgs e) { if (this.lootAdminV.UCLoot.Loot.Id != 0) { currentLoot = this.lootAdminV.UCLoot.Loot; await lootManager.Update(currentLoot); } else { //Recupere la partie par rapport a l'id saisie currentParty = await partyManager.Get(Convert.ToInt32(this.lootAdminV.UCLoot.txtParty.Text)); //affecter au loot la party retrouvé currentLoot.Party = currentParty; //test si l'id du personnage est renseigner ou pas if (this.lootAdminV.UCLoot.txtCharacter.Text != "") { //recupere le personnage par rapport a l'id saisie currentCharacter = await characterManager.Get(Convert.ToInt32(this.lootAdminV.UCLoot.txtCharacter.Text)); //affecte le personnage retrouvé currentLoot.Character = currentCharacter; //rajouter currentCharacter.Equipement.Add(currentLoot); } else { currentParty.Bag.Add(currentLoot); } await lootManager.Insert(currentLoot); //TODO verifier si l'id de l'item est bien présent ... this.lootAdminV.LUCLoot.Obs.Add(currentLoot); this.lootAdminV.UCLoot.Loot = currentLoot; } }
/** * Callback on "Save" button */ private async void BtnValidate_Click(object sender, System.Windows.RoutedEventArgs e) { currentAddress = this.addressAdmin.UCAddress.Address; if (currentAddress.Id != 0) { try { await addressManager.Update(currentAddress); } catch (DbEntityValidationException dbe) { validate(); MessageBox.Show("One or more fields are not valid."); Console.WriteLine(dbe); } } else { try { MySQLManager <StreetNumber> snManager = new MySQLManager <StreetNumber>(); await snManager.Insert(currentAddress.StreetNumber); await addressManager.Insert(currentAddress); this.addressAdmin.UCAddressList.AddItem(currentAddress); } catch (DbEntityValidationException dbe) { validate(); MessageBox.Show("One or more fields are not valid."); Console.WriteLine(dbe); } } }
private async void TestEF6C1C2() { Class1 c1 = new Class1(); EntityGenerator <Class1> generatorClass1 = new EntityGenerator <Class1>(); c1 = generatorClass1.GenerateItem(); EntityGenerator <Class2> generatorClass2 = new EntityGenerator <Class2>(); for (int i = 0; i < 10; i++) { c1.Addresses.Add(generatorClass2.GenerateItem()); } MySQLManager <Class1> managerClass1 = new MySQLManager <Class1>(DataConnectionResource.LOCALMYSQL); c1 = await managerClass1.Insert(c1); Class1 c11 = await managerClass1.Get(c1.Id); //Class1 client = managerClass1.DbSetT.SqlQuery("SELECT * FROM " + Class1Schema.TABLE + " WHERE id = 1",new object[] { }).ToListAsync().Result[0]; //Class1 client = managerClass1.DbSetT.SqlQuery("@param1, @param2, @param3", // new SqlParameter("param1", "SELECT * FROM "), // new SqlParameter("param2", Class1Schema.TABLE), // new SqlParameter("param3", " WHERE id = 1")).FirstAsync().Result; //var result = await managerClass1.DbSetT.SqlQuery("SELECT " + Class1Schema.ID + ", " + Class1Schema.NAME + ", " + Class1Schema.SURNAME + ", " + Class1Schema.ADDRESS_ID +" FROM " + Class1Schema.TABLE).ToListAsync(); //Func<Class1, Boolean> testFunction = new Func<Class1, bool>((x, y) => //{ // if (true) // { // return true; // } // else // { // return false; // } //}); //var result1 = managerClass1.DbSetT.SqlQuery("SELECT * FROM "+ Class1Schema.TABLE + ";").AllAsync(testFunction); String queryString = string.Format("SELECT * FROM {0} {1} {2} {3} {4};", Class1Schema.TABLE, "WHERE", Class1Schema.NAME, "LIKE", "'%s'"); queryString = string.Format("SELECT * FROM {0};", Class1Schema.TABLE); var result = await managerClass1.DbSetT.SqlQuery(queryString).ToListAsync(); Criteria criteria = new Criteria(DbAction.SELECT, EnumString.GetStringValue(DbSelector.ALL)); criteria.AddDbLink(Class1Schema.TABLE, DbLinks.FROM); criteria.AddDbLink(Class2Schema.TABLE, DbLinks.INNERJOIN, new LinkCondition(Class1Schema.PREFIX_ADDRESS_ID, Class2Schema.PREFIX_ID)); criteria.AddCriterion(new Criterion(DbVerb.EMPTY, Class1Schema.NAME, DbOperator.LIKE, "'%s'")); criteria.AddCriterion(new Criterion(DbVerb.OR, Class1Schema.SURNAME, DbOperator.IN, "('RebeckaGotts', 'JesseAguas')")); String value = criteria.MySQLCompute(); var result1 = await managerClass1.CustomQuery(criteria); //MySQLManager<Class2> managerClass2 = new MySQLManager<Class2>(DataConnectionResource.LOCALMYSQL); //Criteria criteria1 = new Criteria(DbAction.DELETE, Class1Schema.ALL_TABLE_ELEMENT + ", " + Class2Schema.ALL_TABLE_ELEMENT); //criteria1.AddDbLink(Class2Schema.TABLE, DbLinks.FROM); //criteria1.AddDbLink(Class1Schema.TABLE, DbLinks.INNERJOIN, new LinkCondition(Class2Schema.PREFIX_CLASS1_ID, Class1Schema.PREFIX_ID)); //criteria1.AddCriterion(new Criterion(DbVerb.EMPTY, Class2Schema.PREFIX_CLASS1_ID, DbOperator.SUPERIOREQUAL, "4")); //String value1 = criteria1.MySQLCompute(); //await managerClass2.CustomQuery(criteria1); }
private async void CreateCastle() { GameViewModel.Instance.MainCastle.Name = popUp.UsernameTB.Text; await myCastleManager.Insert(GameViewModel.Instance.MainCastle); }
public async Task <IHttpActionResult> Post(T value) { await manager.Insert(value); return(Ok(value)); }