public override void Update() { if (Selected != null) { DomaineItemViewModel itemToUpate = Selected; DomaineItemWindow window = new DomaineItemWindow(itemToUpate); window.ShowDialog(); if (window.DialogResult.HasValue && window.DialogResult == true) { try { Domaine toUpdate = itemToUpate.ToEntity(); MyDb.SaveChanges(); ReloadDatas(); return; } catch (Exception e) { MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message); } } MyDb = new MegaProductionBDDEntities(); } }
public override void Delete() { if (Selected != null) { if (MessageBox.Show("Souhaitez-vous réellement supprimer cet élément ?", "Suppression", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { try { Domaine toRemove = Selected.ToEntity(); MyDb.Domaine.Remove(toRemove); MyDb.SaveChanges(); ReloadDatas(); return; } catch (Exception e) { MessageBox.Show("Erreur lors de la sauvegarde des données : " + e.Message); } } MyDb = new MegaProductionBDDEntities(); } }
public async Task <ActionResult <Domaine> > PostAsync(Domaine entity) { var k = new AddGeneric <Domaine>(entity); var result = await _mediator.Send(k); return(Ok(result)); }
public async Task RemoveDomaine_RemovesDomainInStorage() { DecisionModel currentPrototype = this.Prototype; Domaine firstDomain = currentPrototype.Domaines.Single(); Domaine secondDomain = TestingDomaineGenerator.DifferentByName().Take(1).Single(); // Bloc 1 : création initiale de la décision { DecisionModel decision = currentPrototype; decision.Domaines.Add(secondDomain); Assert.AreEqual(2, decision.Domaines.Count); await this.Persister.StoreDecisionAsync(decision); } // Bloc 2 : Enlever un domaine à la décision { DecisionModel decision = (await this.Persister.FetchAllAsync()).Single(); decision.Domaines.Remove(secondDomain); await this.Persister.StoreDecisionAsync(decision); } // Bloc final : vérification que la décision ne contient qu'un seul domaine { DecisionModel decision = (await this.Persister.FetchAllAsync()).Single(); Assert.IsTrue(decision.Domaines.Contains(firstDomain)); Assert.IsFalse(decision.Domaines.Contains(secondDomain)); } }
/// <inheritdoc /> public IEnumerable <DecisionModel> FetchAll() { var decisionBuilders = new List <DecisionBuilder>(); foreach (RssChannel channel in this.Channels) { var currentDomaine = new Domaine(channel.title); foreach (RssItem item in channel.Items()) { DecisionBuilder builder = decisionBuilders .SingleOrDefault(element => BuilderContainsItem(element, item)); if (builder == null) { builder = FromItem(item); decisionBuilders.Add(builder); } builder.Domaines.Add(currentDomaine); } } return(decisionBuilders.Select(builder => builder.Build())); }
public Domaine Chercher(string nom) { Domaine d = null; if (con.State != ConnectionState.Open) { con.Open(); } try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Domaine WHERE NomDomaine='" + nom + "'"; IDataReader reader = com.ExecuteReader(); if (reader.Read()) { d = reader2Domaine(reader); } } finally { con.Close(); } return(d); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Intitule")] Domaine domaine) { if (id != domaine.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(domaine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DomaineExists(domaine.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(domaine)); }
public async Task <ActionResult <Domaine> > Put([FromBody] Domaine etu) { var k = new PutGeneric <Domaine>(etu); var result = await _mediator.Send(k); return(Ok(result)); }
public Domaine ToEntity() { Domaine toReturn = associated_entity; toReturn.Libelle = Libelle; return(toReturn); }
private Domaine reader2Domaine(IDataReader reader) { Domaine d = new Domaine(); d.Id = Convert.ToInt32(reader["IdDomaine"]); d.NomDomaine = reader["NomDomaine"].ToString(); return(d); }
private RssChannel FactoryNewChannel(Domaine domaine) { return(new RssChannel { title = domaine.Nom, link = new Uri(this._baseUri, FileNameForDomaine(domaine)).ToString() }); }
public ActionResult DeleteConfirmed(int id) { Domaine domaine = db.Domaines.Find(id); db.Domaines.Remove(domaine); db.SaveChanges(); return(RedirectToAction("Index")); }
public DomaineRssFeed Find(Domaine domaine) { if (!this._cache.ContainsKey(domaine)) { this._cache[domaine] = new DomaineRssFeed(this._directory, domaine, this._baseUri); } return(this._cache[domaine]); }
public ActionResult Create(MarcheViewModel marche) { var userId = User.Identity.GetUserId(); Projet pro = dbmetier.Projets.Find(marche.id_projet); Marché mar = new Marché(); mar.Délai = marche.Délai; mar.date_fin = marche.date_fin; mar.date_debut = System.DateTime.Now; mar.budget_prevu = marche.budget_prevu; mar.id_projet_fk = marche.id_projet; mar.matricule = marche.matricule; mar.id_responsable_fk = userId; dbmetier.Marché.Add(mar); dbmetier.SaveChanges(); foreach (var item in marche.listeprestataire) { Models.Participation par = new Models.Participation(); par.id_marché_participation = mar.id_marché; par.id_prestataire_participation = item; dbmetier.Participations.Add(par); dbmetier.SaveChanges(); } foreach (MissionViewModel item in marche.listMission) { //ajout de domaine Domaine domaine = dbmetier.Domaines.Where(x => x.libelle_domaine == item.domaine).FirstOrDefault(); Mission mision = new Mission { id_mission = item.id_mission, libelle_mission = item.libelle_mission, id_domaine_mission_fk = domaine.id_domaine, id_marche_mission = mar.id_marché }; dbmetier.Missions.Add(mision); dbmetier.SaveChanges(); foreach (var profillib in item.listeprofils) { Profil prof = dbmetier.Profils.Where(x => x.libelle_profil == profillib.libelle).FirstOrDefault(); Affectation_profils afectation = new Affectation_profils { id_mission_affectation = mision.id_mission, id_profils_affectation = prof.id_profil, charge_profil = profillib.charge }; dbmetier.Affectation_profils.Add(afectation); dbmetier.SaveChanges(); } } return(Content("<script language='javascript' type='text/javascript'>alert('sucsssflly!');</script>")); }
public JsonResult GetTimeConnection(string EndTime) { Domaine d = new Domaine(); d.Time = EndTime; d.Nom_domaine = "bla"; d.motdepasse = "bla"; db.domaines.Add(d); db.SaveChanges(); return(Json(EndTime, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "Id,Designation,DepartementId")] Domaine domaine) { if (ModelState.IsValid) { db.Entry(domaine).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartementId = new SelectList(db.Departements, "Id", "Designation", domaine.DepartementId); return(View(domaine)); }
public ActionResult Create([Bind(Include = "Id,Designation,DepartementId")] Domaine domaine) { if (ModelState.IsValid) { db.Domaines.Add(domaine); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartementId = new SelectList(db.Departements, "Id", "Designation", domaine.DepartementId); return(View(domaine)); }
public void nbTypeActiviteTest() { Domaine d = new Domaine("Toto"); d.ajouterActivite(new TypeActivite("Tata")); d.ajouterActivite(new TypeActivite("Tota")); int nb = 5; d.nbTypeActivite(ref nb); Assert.IsTrue(nb == 7, "nbTypeActivite n'a pas ajouté le bon nombre d'activités"); }
public void accesseursTest() { int[] col = { 0, 1, 2 }; Domaine d = new Domaine("Toto", col); d.ajouterActivite(new TypeActivite("Tata")); d.ajouterActivite(new TypeActivite("Tota")); Assert.IsNotNull(d.getActivites(), "getActivites ne renvoie pas la bonne valeur"); Assert.AreEqual(d.getCouleur(), col, "getCouleur ne renvoie pas la bonne valeur"); Assert.AreEqual(d.getNom(), "Toto", "getNom ne renvoie pas la bonne valeur"); Assert.IsNotNull(d.getNomActivites(), "getNomActivites ne renvoie pas la bonne valeur"); }
public void ajouterActiviteTest() { Domaine d = new Domaine("Toto"); Assert.IsNotNull(d.getActivites(), "La liste des activités ne devrait pas être nulle"); Assert.IsTrue(d.getActivites().Count == 0, "La liste des activités devrait être vide"); d.ajouterActivite(new TypeActivite("Tata")); d.ajouterActivite(new TypeActivite("Tata")); d.ajouterActivite(new TypeActivite("Tata")); Assert.IsTrue(d.getActivites().Count == 3, "Une activité n'a pas été ajoutée"); }
public DomaineRssFeed(IDirectory directory, Domaine domaine, Uri baseUri) { this.Domaine = domaine; this._file = directory.CreateOrReturnFile(FileName(domaine)); RssChannel channel = this.ReadFile() ?? new RssChannel(); var fileUri = new Uri(baseUri, FileName(domaine)); channel.link = fileUri.ToString(); channel.title = this.Domaine.Nom; this.WriteFile(channel); }
public void Supprimer(Domaine d) { con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "DELETE FROM Domaine WHERE IdDomaine=" + d.Id.ToString(); com.ExecuteNonQuery(); } finally { con.Close(); } }
// GET: Domaines/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Domaine domaine = db.Domaines.Find(id); if (domaine == null) { return(HttpNotFound()); } return(View(domaine)); }
public void supprimerActiviteTest() { Domaine d = new Domaine("Toto"); d.ajouterActivite(new TypeActivite("Tata")); d.ajouterActivite(new TypeActivite("Tota")); TypeActivite ta = new TypeActivite("Tato"); d.ajouterActivite(ta); d.supprimerActivite(ta); Assert.IsTrue(d.getActivites().Count == 2, "Une activité n'a pas été supprimée"); Assert.IsNull(d.getActivites().Find(e => (e.getNom().Equals(ta.getNom()))), "L'activité supprimée n'est pas la bonne"); }
public void Sauver(Domaine d) { con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "UPDATE Domaine SETNomDomaine='" + d.NomDomaine + "' WHERE IdDomaine=" + d.Id.ToString(); com.ExecuteNonQuery(); } finally { con.Close(); } }
public ActionResult Itentification(Domaine d) { Session["Here"] = null; if (ModelState.IsValid) { var i = db.domaines.SingleOrDefault(c => c.Nom_domaine == d.Nom_domaine && c.motdepasse == d.motdepasse); if (i != null) { Session["Here"] = "WeAreHere"; return(RedirectToAction("LogIn")); } } return(View(d)); }
// GET: Domaines/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Domaine domaine = db.Domaines.Find(id); if (domaine == null) { return(HttpNotFound()); } ViewBag.DepartementId = new SelectList(db.Departements, "Id", "Designation", domaine.DepartementId); return(View(domaine)); }
public DomaineItemViewModel(Domaine domaine, MegaProductionBDDEntities MyDb) { if (domaine == null) { domaine = new Domaine(); } this.associated_entity = domaine; this.Identifiant = domaine?.Identifiant ?? 0; this.Libelle = domaine?.Libelle; ValiderCommand = new RelayCommand(Valider); CancelCommand = new RelayCommand(Annuler); }
public ActionResult ajouterMission(MVM mission, int id_ordre, int id_marche) { //ajout de domaine int budget_mission = 0, budget_restant = 0; Participation par = dbmetier.Participations.Where(a => a.id_marché_participation == id_marche).First(); ICollection <Participation_profil> listparti = par.Participation_profil; foreach (var item in mission.listeprofils) { budget_mission += item.charge * (int)listparti.Where(a => a.Profil.libelle_profil == item.libelle).Select(a => a.cout_unit_ht).FirstOrDefault(); } Participation participation = dbmetier.Participations.Where(a => a.id_marché_participation == id_marche).FirstOrDefault(); Marché marche = dbmetier.Marché.Find(id_marche); budget_restant = (int)participation.budget_prestation - (int)marche.montant_total; if (budget_mission <= budget_restant) { marche.montant_total += budget_mission; Ordre_service ordre = dbmetier.Ordre_service.Find(id_ordre); ordre.date_modification = System.DateTime.Now; Domaine domaine = dbmetier.Domaines.Where(x => x.libelle_domaine == mission.mission.Domaine.libelle_domaine).FirstOrDefault(); Mission mision = new Mission { libelle_mission = mission.mission.libelle_mission, id_domaine_mission_fk = domaine.id_domaine, id_marche_mission = marche.id_marché , id_ordreservice_fk = ordre.id_ordre_service }; dbmetier.Missions.Add(mision); dbmetier.SaveChanges(); foreach (var profillib in mission.listeprofils) { Profil prof = dbmetier.Profils.Where(x => x.libelle_profil == profillib.libelle).FirstOrDefault(); Affectation_profils afectation = new Affectation_profils { id_mission_affectation = mision.id_mission, id_profils_affectation = prof.id_profil, charge_profil = profillib.charge }; dbmetier.Affectation_profils.Add(afectation); dbmetier.SaveChanges(); } } return(null); }
public async Task <IActionResult> Create([Bind("Id,Intitule")] Domaine domaine) { if (AlreadyExists(domaine.Intitule)) { ModelState.AddModelError("Domaine", "Erreur : Existe déjà"); } if (ModelState.IsValid) { _context.Add(domaine); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(domaine)); }
/// <summary> /// Met à jour l'état en bas pour l'utilisateur /// </summary> /// <param name="typeEtat">texte : "Filtrage", "Ajout", "Modification", "Suppression", "Look", "" ("" = Chargement)</param> /// <param name="dao">un objet Commande_Fournisseur soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param> public void MiseAJourEtat(string typeEtat, Domaine lib) { //Je racalcul le nombre max d'élements this.recalculMax(); //En fonction de l'libion, j'affiche le message if (typeEtat == "Filtrage") { ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "filtrage des domaines terminé : " + this.mesDomaines.Count() + " / " + this.max; } else if (typeEtat == "Ajout") { //J'ajoute la commande_fournisseur dans le linsting this.mesDomaines.Add(lib); //Je racalcul le nombre max d'élements après l'ajout this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'un domaine dénommé '" + lib.Libelle + "' effectué avec succès. Nombre d'élements : " + this.mesDomaines.Count() + " / " + this.max; } else if (typeEtat == "Modification") { //Je raffraichis mon datagrid this._DataGridMain.Items.Refresh(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Modification du domaine dénommé : '" + lib.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.mesDomaines.Count() + " / " + this.max; } else if (typeEtat == "Suppression") { //Je supprime de mon listing l'élément supprimé this.mesDomaines.Remove(lib); //Je racalcul le nombre max d'élements après la suppression this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Suppression du domaine dénommé : '" + lib.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.mesDomaines.Count() + " / " + this.max; } else if (typeEtat == "Look") { } else { ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Chargement des domaines terminé : " + this.mesDomaines.Count() + " / " + this.max; } //Je retri les données dans le sens par défaut this.triDatas(); //J'arrete la progressbar ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; }
/// <summary> /// Ajoute un nouveau domaine à la liste à l'aide d'une nouvelle fenêtre /// </summary> public Domaine Add() { //Affichage du message "ajout en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'un domaine en cours ..."; //Initialisation de la fenêtre DomaineWindow domaineWindow = new DomaineWindow(); //Création de l'objet temporaire Domaine tmp = new Domaine(); //Mise de l'objet temporaire dans le datacontext domaineWindow.DataContext = tmp; //booléen nullable vrai ou faux ou null bool? dialogResult = domaineWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { //Si j'appuie sur le bouton Ok, je renvoi l'objet banque se trouvant dans le datacontext de la fenêtre return (Domaine)domaineWindow.DataContext; } else { try { //On détache le domaine ((App)App.Current).mySitaffEntities.Detach((Domaine)domaineWindow.DataContext); } catch (Exception) { } //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'un domaine annulé : " + this.mesDomaines.Count() + " / " + this.max; return null; } }