Example #1
0
        private bool isDispo(string txt, CreneauDef c)
        {
            txt = txt.ToLower();
            if (c.Debut.Hour >= 6 && c.Fin.Hour <= 13 && c.Fin.Hour >= 6)
            {
                if (txt.Contains("matin"))
                {
                    return(true);
                }
            }
            if (c.Debut.Hour >= 12 && c.Fin.Hour <= 19 && c.Fin.Hour >= 12)
            {
                if (txt.Contains("après"))
                {
                    return(true);
                }
            }

            if (c.Debut.Hour >= 18 || c.Fin.Hour <= 2)
            {
                if (txt.Contains("soir"))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        // GET: Admin
        public ActionResult GenerateCreneauDef()
        {
            if (db.Creneaux.Count() > 0)
            {
                throw new ArgumentException("Creneau non vide");
            }

            int duree = db.Confs.First(s => s.IsCurrent).DureeCreneauMinute;

            foreach (var j in db.JourEvenements)
            {
                DateTime cur = j.DateDebut;
                int      i   = 0;
                while (cur < j.DateFin)
                {
                    CreneauDef d = new CreneauDef()
                    {
                        JourEvenement = j,
                        NoCreneau     = i
                    };
                    i++;
                    cur = cur.AddMinutes(duree);
                    db.CreneauDefs.Add(d);
                }
            }
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }