public CreneauDefViewModel(Tache t, IEnumerable <JourEvenement> jours) { Tache = t; Id = t.Id; Creneaux = new Dictionary <int, Dictionary <int, Creneau> >(); foreach (var j in jours) { var l = new Dictionary <int, Creneau>(); Creneaux.Add(j.Id, l); foreach (var d in j.CreneauDefs) { Creneau c = new Creneau() { CreneauDefId = d.Id, CreneauDef = d, TacheId = Tache.Id, NbBenevoleMax = 0, NbBenevoleMin = 0 }; var old = t.Creneaux.FirstOrDefault(s => s.CreneauDef.NoCreneau == d.NoCreneau && s.CreneauDef.JourId == d.JourId); if (old != null) { c.NbBenevoleMin = old.NbBenevoleMin; c.NbBenevoleMax = old.NbBenevoleMax; } l.Add(d.NoCreneau, c); } } }
private void CalendarCtrlClasse_RemoveCreneauEvent(object sender, Creneau e) { try { CalendarCtrlClasse classe = sender as CalendarCtrlClasse; CalendrierCtrl.RemoveCtrlClasse(classe); CalendarManager.Instance.RemoveCreneau(e); if (e.Column != Enums.ColumnSpanType.Full) { Creneau conflictCreneau = CalendarManager.Instance.ListCreneauChoosed.Single(x => x.ID == e.ConflitCreneauId); conflictCreneau.Column = Enums.ColumnSpanType.Full; conflictCreneau.ConflitCreneauId = 0; } } catch (Exception ex) { MessageBox.Show("Problème lors de la suppression du créneau " + (e.Classe != null ? e.Classe.Libelle : "") + "-" + e.Activite.Libelle + " : \n\n" + ex.Message); } finally { FillCalendar(); } }
public void testStates() { entretient_control entretient_Control = new entretient_control(); Creneau creneau = entretient_Control.getCreneauInAnyRoom(new DateTime(2019, 4, 19, 19, 00, 00), new DateTime(2019, 4, 19, 21, 00, 00)); Assert.IsNotNull(creneau); }
private void Valider_Click(object sender, RoutedEventArgs e) { if (ComboDays.SelectedItem == null || ComboHours.SelectedItem == null || ComboDuree.SelectedItem == null) { return; } string day = ComboDays.SelectedItem as string; Days dayChoosed = GetDayByStr(day); HourModel hour = ComboHours.SelectedItem as HourModel; DureeModel duree = ComboDuree.SelectedItem as DureeModel; string libelleAffiche = TxtBoxLibelle.Text; Creneau creneauChoosed = new Creneau() { Activite = DataManager.Instance.ActiviteChoosed, Classe = CurrentClasse, Jour = dayChoosed, Duree = duree, Hour = hour, Column = ColumnSpanType.Full, LibelleAffiche = string.IsNullOrEmpty(libelleAffiche) ? CurrentClasse.Libelle : libelleAffiche, ConflitCreneauId = 0 }; CreneauChoosed?.Invoke(this, creneauChoosed); }
public ActionResult DeleteConfirmed(int id) { Creneau creneau = db.Creneaux.Find(id); db.Creneaux.Remove(creneau); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AssertTwoCreneauNotEqualsAreNotEquals() { var duration = 10; _creneau1 = new Creneau(DateTime.Now, duration); _creneau2 = new Creneau(DateTime.Now, duration); Assert.False(_creneau1.Equals(_creneau2)); }
public void AssertThatSalleIsAvailableWhenNoCreneau() { Salle salle = new Salle("A07", 0); DateTime date = DateTime.Now; Creneau creneau = new Creneau(date, 10); Assert.True(salle.EstDisponible(creneau)); }
public void Creneau_devrait_être_egual_au_même_creneau() { DateTime date = new DateTime(2020, 1, 10, 12, 00, 00); TimeSpan dureeDeCreneau = TimeSpan.FromHours(5); Creneau sut = new Creneau(date, dureeDeCreneau); Assert.That(sut, Is.EqualTo(new Creneau(date, dureeDeCreneau))); }
public Entretien(Candidat candidat, ConsultantRecruteur consultantRecruteur, Creneau creneau) { ID = Guid.NewGuid(); Statut = "Planifié"; Candidat = candidat; ConsultantRecruteur = consultantRecruteur; Creneau = creneau; }
public ActionResult Edit(int id, CreneauDefViewModel vm) { Tache tache = db.Taches.Include("Creneaux.CreneauDef").First(s => s.Id == id); var creneauxDef = db.CreneauDefs.ToList(); var dico = new Dictionary <int, JourEvenement>(); foreach (var j in db.JourEvenements) { dico.Add(j.Id, j); } ViewBag.Jours = dico; if (ModelState.IsValid) { Regex r = new Regex(@"\[([0-9]+)\]"); foreach (var key in Request.Form.AllKeys.Where(k => k.Contains("Creneaux") && k.Contains("NbBenevoleMin"))) { var m = r.Match(key); int jourId = int.Parse(m.Groups[0].Captures[0].Value.Trim(new char[] { '[', ']' })); m = m.NextMatch(); int noCreneau = int.Parse(m.Groups[0].Captures[0].Value.Trim(new char[] { '[', ']' })); var min = int.Parse(Request.Form[key].ToString()); var max = int.Parse(Request.Form[key.Replace("NbBenevoleMin", "NbBenevoleMax")].ToString()); var cre = tache.Creneaux.FirstOrDefault(s => s.CreneauDef.JourId == jourId && s.CreneauDef.NoCreneau == noCreneau); if (min == 0 && cre != null) { db.Creneaux.Remove(cre); } else if (min > 0) { if (max <= min) { max = min; } if (cre == null) { cre = new Creneau() { TacheId = tache.Id, CreneauDefId = creneauxDef.First(s => s.NoCreneau == noCreneau && s.JourId == jourId).Id, }; db.Creneaux.Add(cre); } cre.NbBenevoleMax = max; cre.NbBenevoleMin = min; } } db.SaveChanges(); CreneauDefViewModel newVm = new CreneauDefViewModel(db.Taches.Include("Creneaux.CreneauDef").First(s => s.Id == id), db.JourEvenements.Include("CreneauDefs")); return(View(newVm)); } return(View(vm)); }
public bool AjouterIndisponibilite(Creneau indispo) { if (!EstDisponible(indispo)) { return(false); } _creneauxIndisponibles.Add(indispo); return(_creneauxIndisponibles.IndexOf(indispo) >= 0); }
public void Setup() { creneau = new Creneau(new DateTime(2019, 10, 10, 9, 0, 0), TimeSpan.FromHours(2)); statut = EntretienStatut.Planifier; candidatCsharp = new Candidat("yoyo", Specialite.csharp, TimeSpan.FromDays(1000)); recruteurCsharpExperimenter = new Recruteur("Arnaud", Specialite.csharp, TimeSpan.FromDays(20000)); salle1 = new Salle("Wagram", SalleStatut.Libre); salle2 = new Salle("Republique", SalleStatut.Libre); }
private void ClasseCtrl_CreneauChoosed(object sender, Creneau e) { CalendarCtrlClasse classe = CreateCalendarClasseCtrlByCreneau(e); bool IsAdded = CalendarManager.Instance.AddCreneau(e, out int countConflictCreneau, out List <Creneau> conflitCreneaux); if (IsAdded) { CalendrierCtrl.AddCtrlClass(classe); } else if (!IsAdded && countConflictCreneau < MAXIMUM_CONFLIT_STACK) { string message = "Ce créneau est déjà pris !"; foreach (Creneau c in conflitCreneaux) { message += " \n\n" + (c.Classe != null ? c.Classe.Libelle : "") + " | " + c.Activite.Libelle + "\n" + c.StartHour.ToString("hh\\:mm") + " à " + c.EndHour.ToString("hh\\:mm"); } message += "\n\n Voulez-vous le partagez ?"; if (MessageBox.Show(message, "Attention", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { //No } else //Yes { //On ajoute le creneau CalendarManager.Instance.ListCreneauChoosed.Add(e); //On sépare les creneaux int nbConflit = 0; for (int index = 0; index < conflitCreneaux.Count; index++) { conflitCreneaux[index].Column = (Enums.ColumnSpanType)index; conflitCreneaux[index].ConflitCreneauId = e.ID; nbConflit++; } e.ConflitCreneauId = conflitCreneaux.First().ID; e.Column = (Enums.ColumnSpanType)nbConflit; FillCalendar(); } } else { string message2 = "Ce créneau est déjà pris !"; foreach (Creneau c in conflitCreneaux) { message2 += " \n\n" + (c.Classe != null ? c.Classe.Libelle : "") + " | " + c.Activite.Libelle + "\n" + c.StartHour.ToString("hh\\:mm") + " à " + c.EndHour.ToString("hh\\:mm"); } MessageBox.Show(message2); } }
public void AssertTwoCreneauEqualsAreEquals() { DateTime dateTime = DateTime.Now; var duration = 10; _creneau1 = new Creneau(dateTime, duration); _creneau2 = new Creneau(dateTime, duration); Assert.True(_creneau1.Equals(_creneau2)); }
public void createCreneauSpecificRoomFail() { entretient_control entretient_Control = new entretient_control(); Creneau creneau = entretient_Control.getCreneau(new DateTime(2019, 4, 19, 19, 00, 00), new DateTime(2019, 4, 19, 21, 00, 00), "A06"); Creneau creneau2 = entretient_Control.getCreneau(new DateTime(2019, 4, 19, 20, 00, 00), new DateTime(2019, 4, 19, 22, 00, 00), "A06"); Assert.IsNotNull(creneau); Assert.IsNotNull(creneau2); Assert.AreNotEqual(creneau.salle, creneau2.salle); }
public void Creneau_ne_devrait_pas_être_egual_a_un_creneau_different() { DateTime date = new DateTime(2020, 1, 10, 12, 00, 00); TimeSpan dureeDeCreneau = TimeSpan.FromHours(7); TimeSpan autreDureeDeCreneau = TimeSpan.FromHours(10); Creneau sut = new Creneau(date, dureeDeCreneau); Assert.That(sut, Is.Not.EqualTo(new Creneau(date, autreDureeDeCreneau))); }
public void createCreneauTimeStepOver() { entretient_control entretient_Control = new entretient_control(); Creneau creneau = entretient_Control.getCreneauInAnyRoom(new DateTime(2019, 4, 19, 16, 00, 00), new DateTime(2019, 4, 19, 18, 00, 00)); Creneau creneau2 = entretient_Control.getCreneauInAnyRoom(new DateTime(2019, 4, 19, 17, 00, 00), new DateTime(2019, 4, 19, 19, 00, 00)); Assert.IsNotNull(creneau); Assert.IsNotNull(creneau2); Assert.AreNotEqual(creneau.salle, creneau2.salle); }
public static Entete One(Creneau creneau, DateTime date) { try { return(EnteteDao.getOneEntete(creneau, date)); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public void AssertThatSalleHasCrenauxAfterAddedOne() { Salle salle = new Salle("A07", 0); DateTime date = DateTime.Now; Creneau creneau = new Creneau(date, 10); Assert.True(salle.EstDisponible(creneau)); bool ajoutCreneau = salle.AjouterIndisponibilite(creneau); Assert.True(ajoutCreneau); }
public void AssertThatSalleCantHaveTwiceSameCreneau() { Salle salle = new Salle("A07", 0); DateTime date = DateTime.Now; Creneau creneau = new Creneau(date, 10); salle.AjouterIndisponibilite(creneau); bool ajoutCreneau = salle.AjouterIndisponibilite(creneau); Assert.False(ajoutCreneau); }
public ActionResult EncadrementInscrits(int idCreneau) { string userid = User.Identity.GetUserId(); Creneau cre = db.Creneaux.FirstOrDefault(c => c.Id == idCreneau && c.ApplicationUserID == userid); // on cherche si l'encadrant encandre bien le creneau qui posséde l'id idCreneau if (cre == null) { return(new HttpNotFoundResult("Ce creneau n'existe pas ou n'est pas encadré par vous")); } return(View(cre.CreneauxAdherents)); }
public ActionResult Edit([Bind(Include = "Id,Hdebut,Mdebut,Hfin,Mfin,MedecinId,Timestamp")] Creneau creneau) { if (ModelState.IsValid) { db.Entry(creneau).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MedecinId = new SelectList(db.Medecins, "Id", "Titre", creneau.MedecinId); return(View(creneau)); }
// GET: InscriptionCreneau public ActionResult Index(int id) { //recupere le creneau dont l'id est passe en parametre Creneau creneau = context.Creneau .Where(x => x.Id_Creneau == id) .FirstOrDefault(); //passe a la vue le creneau et son id ViewBag.Creneau = creneau; ViewBag.idCreneau = creneau.Id_Creneau; //enregistre dans la session l'id du creneau Session["Creneau"] = creneau.Id_Creneau; //recupere la section a laquelle appartient le creneau Section s = context.Section .Where(x => x.Id_Section == creneau.Section_Id_Section) .FirstOrDefault(); //passe a la vue les informations sur la section ViewBag.SectionId = s.Id_Section; ViewBag.SectionCreneau = s.Nom; ViewBag.PrixSection = s.Prix; //enregistre dans la session l'id de la section Session["S_id"] = s.Id_Section; //recupere le lieu ou se passe le cours du creneau Lieu l = context.Lieu .Where(x => x.Id_Lieu == creneau.Lieu_Id_Lieu) .FirstOrDefault(); //passe a la vue les informations sur le lieu ViewBag.LieuCreneau = l.Nom; ViewBag.AdresseCreneau = l.Adresse; //recupere les informations sur l'encadrant du creneau Personne p = context.Personne .Where(x => x.Id_Personne == creneau.Encadrant) .FirstOrDefault(); //passe a la vue cet encadrant ViewBag.Encadrant = p; //recupere la discipline du creneau Discipline d = context.Discipline .Where(x => x.Id_Discipline == s.Discipline_Id_Discipline) .FirstOrDefault(); //passe le nom de la discipline a la vue ViewBag.CreneauDiscipline = d.Nom_Discipline; //retourne la vue return(View()); }
public ActionResult ModifierCreneau(FormCollection id) { //recupere les donnees recues via le formulaire var ancien = int.Parse(Request.Form["ancien"]); var nouveau = int.Parse(Request.Form["nouveau"]); //recupere l'id de l'adherent dans session int Id = (int)Session["P_id"]; using (var context = new Context_db()) { try { //recupere l'ancien creneau choisi par l'adherent Creneau ancienC = context.Creneau .Where(c => c.Id_Creneau == ancien) .FirstOrDefault(); //recupere le nouveau creneau choisi par l'adherent Creneau nouveauC = context.Creneau .Where(c => c.Id_Creneau == nouveau) .FirstOrDefault(); //met a jour le nombre de places disponibles dans chacun d'entre eux nouveauC.Nombre_Places_Dispo = nouveauC.Nombre_Places_Dispo - 1; ancienC.Nombre_Places_Dispo = ancienC.Nombre_Places_Dispo + 1; //recupere l'adherent Personne adherent = context.Personne .Where(p => p.Id_Personne == Id) .FirstOrDefault(); //met a jour la table inscrits de la base de donnees adherent.Creneau1.Add(nouveauC); adherent.Creneau1.Remove(ancienC); //enregistre les modifications context.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { //affiche les erreurs en cas de probleme dans le try catch foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } } //renvoi la page d'accueil de l'espace personnel de l'utilisateur return(Redirect("/Account/UserPannel")); }
public void AssertThatRecruteurIsAvailableWhenNoCreneau() { Personne recruteurPersonne = new Personne("Antoine", "Sauvignet"); string[] recruteurCompetence = { ".Net", "js", "C" }; Profil recruteurProfil = new Profil(new List <string>(recruteurCompetence), 5); Recruteur recruteur = new Recruteur(recruteurPersonne, recruteurProfil); DateTime date = DateTime.Now; Creneau creneau = new Creneau(date, 10); Assert.True(recruteur.EstDisponible(creneau)); }
public void createEntretient() { entretient_control entretient_Control = new entretient_control(); List <Recruiter> recruiters = entretient_Control.GetRecruteurs().ToList(); Candidate candidate = entretient_Control.GetCandidatByName("MEYER", "Alexandre"); Creneau creneau = entretient_Control.getCreneauInAnyRoom(new DateTime(2019, 4, 22, 16, 00, 00), new DateTime(2019, 4, 22, 18, 00, 00)); Entretien entretien = entretient_Control.CreateEntretient(recruiters, candidate, creneau); Assert.IsNotNull(entretien); Assert.AreEqual(entretien.creneau.heureDebut, new DateTime(2019, 4, 22, 16, 00, 00)); Assert.AreEqual(entretien.creneau.HeureFin, new DateTime(2019, 4, 22, 18, 00, 00)); Assert.AreEqual(entretien.recruiter[1].firstname, recruiters[1].firstname); }
public void AssertThatSalleIsNotAvailableIfTwiceSameCreneau() { Salle salle = new Salle("A07", 0); DateTime date = DateTime.Now; Creneau creneau = new Creneau(date, 10); salle.AjouterIndisponibilite(creneau); bool ajoutCreneau = salle.AjouterIndisponibilite(creneau); salle.AjouterIndisponibilite(creneau); Assert.False(salle.EstDisponible(creneau)); }
// GET: Creneaux/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Creneau creneau = db.Creneaux.Find(id); if (creneau == null) { return(HttpNotFound()); } return(View(creneau)); }
public void AssertThatRecruteurHasCrenauxAfterAddedOne() { Personne recruteurPersonne = new Personne("Antoine", "Sauvignet"); string[] recruteurCompetence = { ".Net", "js", "C" }; Profil recruteurProfil = new Profil(new List <string>(recruteurCompetence), 5); Recruteur recruteur = new Recruteur(recruteurPersonne, recruteurProfil); DateTime date = DateTime.Now; Creneau creneau = new Creneau(date, 10); bool ajoutCreneau = recruteur.AjouterIndisponibilite(creneau); Assert.True(ajoutCreneau); }
private static async Task ProcessWedding() { var blackListedIds = new string[] { "1625842800R141cc6c3-cbc1-4dff-8aa7-0ac268a385de", "1626096600R6abdc24e-0a7d-48ca-8c3c-7e2288c1681d", "1626102000R85523603-22db-480f-946c-d95cc59d3980" }; var config = ConfigurationManager.AppSettings; var uri = config["WeddingUri"]; var dt = DateTime.Now; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("type", config["Type"]), new KeyValuePair <string, string>("key", config["Key"]), new KeyValuePair <string, string>("tStamp", $"{dt:yyyyMMddhhmmss}"), new KeyValuePair <string, string>("idQdt", config["IdQdt"]), new KeyValuePair <string, string>("origine", config["Origine"]), new KeyValuePair <string, string>("idSit", config["IdSit"]), new KeyValuePair <string, string>("dateDeb", $"{dt:dd/MM/yy}"), new KeyValuePair <string, string>("dateFin", config["DateFin"]), new KeyValuePair <string, string>("nbCreneauxAJoindre", config["NbCreneauxAJoindreUri"]), new KeyValuePair <string, string>("listeIdsReserves", config["ListeIdsReserves"]) }); var response = await _client.PostAsync(uri, formContent); var parsedResponse = await response.Content.ReadFromJsonAsync <WeddingResponse>(); if (parsedResponse != null && parsedResponse.creneaux.Count() > 0) { var results = new List <string>(); for (int i = 0; i < parsedResponse.creneaux.Length; i++) { Creneau creneau = parsedResponse.creneaux[i]; if (!blackListedIds.Contains(creneau.id)) { var startDateTime = ConvertFromUnixTimestamp(double.Parse(creneau.start)); results.Add($"Créneau '{creneau.id}' trouvé le : {startDateTime.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss")}"); } } if (results.Any()) { _notifier.Notify(Status.Sucess, "wedding", string.Join("\n", results)); } } else { Console.WriteLine($"=> none :("); } }