public ActionResult Index() { //populate list for the viewmodel list property var vmList = new List <string>(); vmList.Add("Item One"); vmList.Add("Item Two"); vmList.Add("Item Three"); vmList.Add("Item Four"); vmList.Add("Item Five"); //fill VM with data var homeVM = new HomeVM { Message = "Hello Vue!", MenuItems = vmList, RazorMessage = "Hello Razor!", }; //instance of vue var vue = new Vue(); homeVM.VueData = vue.ParseData(homeVM); return(View(homeVM)); }
//combine multiple VMs into a VM of Dictionaries that gets serialized in the view public ActionResult SecondIndex() { var firstVM = new FirstVM { Greeting = "Hello World" }; var secondVM = new FirstVM { Greeting = "Foo" }; var thirdVM = new FirstVM { Greeting = "Bar" }; var fourthVM = new SecondVM { Bye = "Goodbye World" }; var vue = new Vue(); var vueData = new CombinedDataVM { ModelOneData = vue.ParseData(firstVM), ModelTwoData = vue.ParseData(secondVM), ModelThreeData = vue.ParseData(thirdVM), ModelFourData = vue.ParseData(fourthVM) }; return(View(vueData)); }
//transfer an entire viewmodel into a JSON object (No model data-binding with Razor) public ActionResult ThirdIndex() { var userVM = new UserProfileVM { FirstName = "Tony", LastName = "Stark", EmailAddress = "*****@*****.**" }; var vue = new Vue(); var vueData = new VueDataVM { VueData = vue.ParseData(userVM) }; return(View(vueData)); }
private void ModifierExigence_Click(object sender, RoutedEventArgs e) { if (Vue.ExigenceSelectionnee != null && Vue.ExigenceSelectionnee.Name != "Menu") { string CurrentItem = Vue.dash.FormaterToSQLRequest("_" + Vue.dash.NormeSelectionnee.Id + Vue.ExigenceSelectionnee.Name); string CurrentDescription = Vue.dash.SimpleQuoteFormater(Content.Text); string CurrentTitle = Vue.dash.SimpleQuoteFormater(Title.Text); using (ApplicationDatabase context = new ApplicationDatabase()) { string newTableName = Vue.dash.TableFormater(Vue.dash.SimpleQuoteFormater(Vue.dash.FormaterToSQLRequest(Title.Text))); try { //renomme la table var w = context.Database.ExecuteSqlCommand("EXEC sp_rename '" + CurrentItem + "', '" + newTableName + "'"); //modif dans la table Exigence var yy = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Description = '" + Vue.dash.SimpleQuoteFormater(Content.Text) + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'"); var y = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Name = '" + Vue.dash.SimpleQuoteFormater(Title.Text) + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'"); try { //modif dans table parents var ParentName = context.Database.SqlQuery <string>("SELECT Name from Exigences WHERE Id= " + Vue.ExigenceSelectionnee.ForeignKey).FirstOrDefault(); if (ParentName != "Menu" && ParentName != null) { ParentName = Vue.dash.TableFormater(Vue.dash.SimpleQuoteFormater(Vue.dash.FormaterToSQLRequest(ParentName))); var zz = context.Database.ExecuteSqlCommand("UPDATE " + ParentName + " SET Description = '" + Vue.dash.SimpleQuoteFormater(Content.Text) + "' WHERE Titre = '" + Vue.ExigenceSelectionnee.Name + "'"); var z = context.Database.ExecuteSqlCommand("UPDATE " + ParentName + " SET Titre = '" + Vue.dash.SimpleQuoteFormater(Title.Text) + "' WHERE Titre = '" + Vue.ExigenceSelectionnee.Name + "'"); } //actualise l'itemSleceted et la Vue grâce INotifyProperty Vue.ExigenceSelectionnee.Name = Title.Text; Vue.ExigenceSelectionnee.Description = Content.Text; } catch (Exception) { var w2 = context.Database.ExecuteSqlCommand("EXEC sp_rename '" + newTableName + "', '" + CurrentItem + "'"); var yy2 = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Description = '" + CurrentDescription + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'"); var y2 = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Name = '" + CurrentTitle + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'"); MessageBox.Show("Modification impossible", "error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception) { MessageBox.Show("Impossible d'actualiser la BDD", "error", MessageBoxButton.OK, MessageBoxImage.Error); } //switch (ComboBoxStatus.Text) //{ // case "Non Évaluée": // Vue.ExigenceSelectionnee.Status = STATUS.non_evaluee; // break; // case "Non Appliquée": // Vue.ExigenceSelectionnee.Status = STATUS.non_appliquee; // break; // case "Programmée": // Vue.ExigenceSelectionnee.Status = STATUS.programmee; // break; // case "Appliquée": // Vue.ExigenceSelectionnee.Status = STATUS.appliquee; // break; // case "Non Applicable": // Vue.ExigenceSelectionnee.Status = STATUS.non_applicable; // break; // default: // break; //} mw.database.SaveChanges(); Vue.AfficherTreeViewExigences(); Close(); } } else { MessageBox.Show("Selectionner une ligne", "error", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void Window_Closed(object sender, System.EventArgs e) { Vue.dash.FenetreOuverte = false; Vue.AfficherMesureAssociee(); }
public Controller() { this.Model = new Model(); this.Vue = new Vue(); this.Vue.Controller = this; }