public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             throw new Exception("Edition impossible");
         }
         Tache data = _service.Get(id);
         if (data == null)
         {
             throw new Exception("Données manquantes");
         }
         data.Intitule    = collection["Intitule"];
         data.Description = collection["Description"];
         data.IsDone      = (collection["IsDone"] == "false") ? false : true;
         if (!_service.Update(id, data))
         {
             throw new Exception("Erreur dans la base de donnée.");
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.Notification = ex.Message;
         Tache data = _service.Get(id);
         if (data == null)
         {
             return(RedirectToAction("index"));
         }
         return(View(data));
     }
 }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         if (!ModelState.IsValid)
         {
             throw new Exception("Bravo, tu as su faire planter un formulaire sans infos...");
         }
         if (!_service.Delete(id))
         {
             throw new Exception("Votre tache ne peut être supprimée");
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.Notification = ex.Message;
         Tache data = _service.Get(id);
         if (data == null)
         {
             return(RedirectToAction("index"));
         }
         return(View(data));
     }
 }
 public ActionResult Create(TacheFormCreate form)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             throw new Exception("Formulaire non valide");
         }
         if (form.Intitule == null)
         {
             throw new Exception();
         }
         Tache data = new Tache()
         {
             Intitule     = form.Intitule,
             Description  = form.Description,
             AttributeTo  = form.AttributeTo,
             CreationDate = DateTime.Now,
             IsDone       = false
         };
         int id = _service.Insert(data);
         return(RedirectToAction("Details", new { id = id }));
     }
     catch (Exception ex)
     {
         ViewBag.Notification = ex.Message;
         if (form.Intitule == null)
         {
             ModelState.AddModelError("Intitule", "Intitulé obligatoire");
         }
         TacheFormCreate data = new TacheFormCreate();
         return(View(data));
     }
 }
Exemple #4
0
 public ActionResult Edit(int id, TaskModel tm, HttpPostedFileBase Image)
 {
     try
     {
         Tache t = MyTaskService.GetById(id);
         t.name = tm.name;
         //ImageUrl = Image.FileName,
         t.start_date = tm.start_date;
         t.end_date   = tm.end_date;
         t.state      = (State)tm.state;
         t.complexity = (Complexity)tm.complexity;
         t.priority   = tm.priority;
         t.progress   = tm.progress;
         // var path = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName);
         //Image.SaveAs(path);
         MyTaskService.Update(t);
         MyTaskService.Commit();
         // TODO: Add update logic here
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View(tm));
     }
 }
 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);
         }
     }
 }
Exemple #6
0
        public IActionResult Create(Tache item)
        {
            _context.taches.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetTache", new { id = item.TacheID }, item));
        }
 // METHODES =========================
 static void ActualiserListeTaches(ListeTaches lstTch)
 {
     foreach (Tache tch in lstTch.ListeDeTaches)
     {
         tch.ActualiserStatut();
         // Création de nouvelles tâches pour les tâches à périodicité dont la date est passée
         // Todo : pas de création en boucle. Donc un statut pour la tâche qui en a enfanté une autre.
         if (tch.idTacheRepetee == null && tch.ContrainteTps.EstEnRetard() && tch.ContrainteTps.Periodicite != null)
         {
             Tache nwTch = new Tache(
                 tch.Intitule,
                 tch.Duree,
                 Statuts.aFaire,
                 tch.Notes,
                 new ContrainteTemps()
             {
                 DateLimite   = tch.ContrainteTps.AjoutPeriodicite(),
                 DelaiUrgence = tch.ContrainteTps.DelaiUrgence,
                 Periodicite  = tch.ContrainteTps.Periodicite
             }
                 );
             lstTch.AjouterTache(nwTch);
             tch.idTacheRepetee = nwTch.DateCreation;
         }
     }
 }
        static void Main(string[] args)
        {
            GestionTachesContext context = new GestionTachesContext();

            // Initialisation du modèle
            Annuaire     AnnuaireUtilisateurs = new Annuaire(context);
            Registre     BaseRegistres        = new Registre(context);
            GestionTache GestionnaireTaches   = new GestionTache();

            Tache.lastPID = 1;
            Utilisateur     user;
            ElementRegistre entry;

            user  = AnnuaireUtilisateurs.GetUtilisateur(1);
            entry = BaseRegistres.GetElementRegistre(1);
            Tache tache = GestionnaireTaches.AjouterTache(user, entry);

            entry = BaseRegistres.GetElementRegistre(2);
            tache = GestionnaireTaches.AjouterTache(user, entry);
            user  = AnnuaireUtilisateurs.GetUtilisateur(2);
            entry = BaseRegistres.GetElementRegistre(1);
            tache = GestionnaireTaches.AjouterTache(user, entry);

            Console.ReadKey();
        }
Exemple #9
0
        // CONSTRUCTEUR =========================
        public FenetreEditerContrainte(Tache tch)
        {
            InitializeComponent();
            this.DateCreationTache = tch.DateCreation;
            this.ContrainteTraitee = (tch.ContrainteTps == null) ? new ContrainteTemps() : tch.ContrainteTps;
            this.DataContext       = ContrainteTraitee;

            // Calendrier
            this.cal.SelectedDate = this.ContrainteTraitee.DateLimite;

            // Combobox delai d'urgence
            for (int i = 0; i < 15; i++)
            {
                String str = i < 2 ? " jour" : " jours";
                this.cmbBxDelai.Items.Add(new KeyValuePair <String, int>(i + str, i));
            }
            this.cmbBxDelai.DisplayMemberPath = "Key";
            this.cmbBxDelai.SelectedIndex     = this.ContrainteTraitee.DelaiUrgence == null ? 0 : this.ContrainteTraitee.DelaiUrgence.Days;

            // Combobox periode
            this.ListePeriodes = new List <Periodicite>();
            this.ListePeriodes.Add(new Periodicite(1, UnitesTemps.jour));
            this.ListePeriodes.Add(new Periodicite(1, UnitesTemps.semaine));
            this.ListePeriodes.Add(new Periodicite(2, UnitesTemps.semaine));
            this.ListePeriodes.Add(new Periodicite(1, UnitesTemps.mois));
            this.ListePeriodes.Add(new Periodicite(2, UnitesTemps.mois));
            this.ListePeriodes.Add(new Periodicite(6, UnitesTemps.mois));
            this.cmbBxPeriodicite.ItemsSource   = this.ListePeriodes;
            this.cmbBxPeriodicite.SelectedIndex = this.ContrainteTraitee.Periodicite == null ? 0 : this.ListePeriodes.FindIndex(prd => prd.Equals(this.ContrainteTraitee.Periodicite));
        }
Exemple #10
0
        public async Task <ActionResult <Tache> > PostTache(Tache tache)
        {
            _context.Taches.Add(tache);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTache", new { id = tache.TacheId }, tache));
        }
Exemple #11
0
        // GET: /Tache/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tache tache = db.Taches.Find(id);

            if (tache == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var categories   = db.Categories.ToList();
                var complexites  = db.Complexites.ToList();
                var technologies = db.Technologies.ToList();
                var viewModel    = new TacheInformationViewModel
                {
                    tache        = tache,
                    categories   = categories,
                    complexites  = complexites,
                    technologies = technologies
                };
                return(View(viewModel));
            }
            // return View("Index");
        }
        public IActionResult Put([FromBody] Tache Model)
        {
            if (Model != null)
            {
                using (var scope = new TransactionScope())
                {
                    Tache Otache = _tacheRepository.GetTacheByID(Model.Id);

                    _tacheRepository.UpdateTache(Model);
                    scope.Complete();
                }

                //Notification
                Tache t = _tacheRepository.GetTacheByID(Model.Id);
                if (t.UserId != null && t.UserId != Model.UserId)
                {
                    Notification notification = new Notification()
                    {
                        Nom         = "Nom",
                        Description = $"{t.Utilisateur.Nom} {t.Utilisateur.Prenom}" +
                                      $"vous a ajouté en tant que responsable sur la tache {Model.Nom}.",
                        DateCreation = DateTime.Now,
                        SourceId     = t.Id,
                        UserId       = t.UserId
                    };
                    _notificationRepository.InsertNotification(notification);
                }
                return(new OkResult());
            }
            return(new NoContentResult());
        }
Exemple #13
0
        public IHttpActionResult PutTache(int id, Tache tache)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tache.ID)
            {
                return(BadRequest());
            }

            db.Entry(tache).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TacheExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #14
0
        public bool DropTache(int Id)
        {
            Tache tacheDrop = (Tache)this.Dbstx.TacheTable.Where(T => T.Id == Id);

            this.Dbstx.TacheTable.Remove(tacheDrop);
            return(true);
        }
Exemple #15
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,DateCreation,DateEcheance,Terminee")] Tache tache)
        {
            if (id != tache.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tache);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TacheExists(tache.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tache));
        }
        public IActionResult Post([FromBody] Tache tache)
        {
            using (var scope = new TransactionScope())
            {
                _tacheRepository.InsertTache(tache);
                scope.Complete();
            }
            //Notification
            Tache t = _tacheRepository.GetTacheByID(tache.Id);

            if (t.UserId != null)
            {
                Notification notification = new Notification()
                {
                    Nom         = "Nom",
                    Description = $"{t.Utilisateur.Nom} {t.Utilisateur.Prenom}" +
                                  $"vous a ajouté en tant que responsable sur la tache {tache.Nom}.",
                    DateCreation = DateTime.Now,
                    SourceId     = t.Id,
                    UserId       = t.UserId
                };
                _notificationRepository.InsertNotification(notification);
            }
            return(CreatedAtAction(nameof(Get), new { id = tache.Id }, tache));
        }
Exemple #17
0
        public bool NewTAche(string Ds)
        {
            Tache tache = new Tache();

            tache.Deseigniation = Ds;
            return(this.tacheR.AddTache(tache));
        }
Exemple #18
0
        public async Task <IActionResult> PutTache(int id, Tache tache)
        {
            if (id != tache.TacheId)
            {
                return(BadRequest());
            }

            _context.Entry(tache).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TacheExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #19
0
        private static void FillNewTache(IXLWorksheet sheet, Tache tache, JourEvenement jour, ref int line, Planning p, IEnumerable <Affectation> affectations, bool readableExport)
        {
            IXLCell c = sheet.Cell("A" + line);

            c.Value = tache.Id;


            c       = sheet.Cell("B" + line);
            c.Value = tache.Nom;
            c.Style.Font.FontSize = 20;
            c.Style.Font.Bold     = true;

            line++;
            IXLRow r = sheet.Row(line);
            int    j = FIRST_PLAN_COLUMN;

            foreach (var def in jour.CreneauDefs.OrderBy(s => s.NoCreneau))
            {
                c       = r.Cell(j);
                c.Value = "'" + def.Debut.ToString("HH:mm", CultureInfo.InvariantCulture);
                j++;
            }
            line++;

            int maxB = tache.GetMaxBenevoleByDay(jour.Id);

            for (int i = 0; i < maxB; i++)
            {
                r = sheet.Row(line);
                FIllNewRow(r, jour, tache, p, i == 0, i == maxB - 1, i, affectations, readableExport);
                line++;
            }
        }
        public ActionResult Edit(int id, Tache t)
        {
            HttpClient Client   = new HttpClient();
            var        response = Client.PutAsJsonAsync <Tache>("http://localhost:9080/AdvyteamProject2-web/rest/tache", t).Result;

            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Tache tache = db.Taches.Find(id);

            db.Taches.Remove(tache);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void Effectuer_Tout_ResteAFaireVaut0_EstTermineEstVrai()
        {
            var tache3j = new Tache("Poisson d'avril", new DateTime(2018, 4, 1), _3j_);

            tache3j.Effectuer(_3j_);
            Assert.AreEqual(_0j_, tache3j.ResteAFaire);
            Assert.IsTrue(tache3j.EstTerminee);
        }
        public void Effectuer_1Tier_ResteAFaireVaut2Tiers_EstTermineEstFaux()
        {
            var tache3j = new Tache("Poisson d'avril", new DateTime(2018, 4, 1), _3j_);

            tache3j.Effectuer(_1j_);
            Assert.AreEqual(_2j_, tache3j.ResteAFaire);
            Assert.IsFalse(tache3j.EstTerminee);
        }
Exemple #24
0
 public void IsDone(int id)
 {
     if (DBContext.DB.taches.Select(t => t.Id).Contains(id))
     {
         Tache oldData = this.Get(id);
         oldData.IsDone = true;
     }
 }
 private void TasksListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
 {
     if (TasksListView.SelectedItem != null)
     {
         Tache = Taches.FirstOrDefault(x => x.ID == int.Parse(TasksListView.SelectedItem.ToString().Split('-')[0]));
         TaskDetailsLabel.Text = $"ID: {Tache.ID}\n\n\n\nTechnician ID: {Tache.TechnicianID}\n\n\n\nChamberID: {Tache.ChamberID}\n\n\n\nTaskFinished: {Tache.TaskFinished} \n\n\n\nTask Description: {Tache.TaskDescription}";
     }
 }
        // GET: Tache/Details/5
        public ActionResult Details(int id)
        {
            Tache           tache     = FactoryServices.createServices().getTacheById(id);
            List <Exigence> exigences = FactoryServices.createServices().getExigencesByTache(id);

            ViewBag.Exigences = exigences;
            return(View(tache));
        }
Exemple #27
0
        //DELETE: api/RecWebApi/5
        public IHttpActionResult Delete(int id)
        {
            Tache th = MyService.GetById(id);

            MyService.Delete(th);
            MyService.Commit();
            return(Ok(th));
        }
        public void InitTest()
        {

            var debut = new DateTime(2014, 4, 1);
            var tacheAvril = new Tache("Poisson d'avril", debut, _3j);
      

        }
        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));
        }
Exemple #30
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            Tache c = new Tache();

            c = cs.Get(t => t.id == id);
            cs.Delete(c);
            cs.Commit();
            return(RedirectToAction("Index"));
        }