Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var datefin = Tache.datedemarage.AddDays(Tache.nbjours);

            Console.WriteLine("datefin" + datefin);
            Jalon jalon = _context.jalon.Find(Tache.JalonID);

            if (jalon.datefinprevue != null && jalon.datefinprevue < datefin)
            {
                jalon.datefinprevue = datefin;
                _context.jalon.Update(jalon);
            }
            if (jalon.datefinprevue == null)
            {
                jalon.datefinprevue = datefin;
                _context.jalon.Update(jalon);
            }

            _context.taches.Add(Tache);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index", new{ id = Tache.JalonID }));
        }
Esempio n. 2
0
        public IActionResult Add([FromBody] Jalon Jalon)
        {
            IActionResult result;
            Project       Project = ProjectRepository.GetById(Jalon.ProjectId);

            if (Project != null)
            {
                //on vérifie que l'utilisateur n'est pas un chef et que le projet lui est bien assigné avant de lui transmettre l'exigence
                if (this.GetId() != Project.UserId && !this.IsChief())
                {
                    result = Unauthorized(new { Message = "Vous n'avez pas le droit d'accéder à la ressource demander!" });
                }
                else
                {
                    try
                    {
                        Jalon.DateLivPrev = DateTime.Now;
                        this.JalonRepository.Add(Jalon);
                        this.JalonRepository.SaveChanges();
                        result = Ok(new { Message = "Insertion effectué" });
                    }
                    catch
                    {
                        result = StatusCode(500);
                    }
                }
            }
            else
            {
                result = NotFound(new { Message = "Le projet n'éxiste pas" });
            }

            return(result);
        }
Esempio n. 3
0
        public IActionResult Create(Jalon item)
        {
            _context.jalon.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetJalon", new { id = item.JalonID }, item));
        }
Esempio n. 4
0
        public IActionResult GetTask(int id)
        {
            IActionResult result;
            Jalon         Jalon = JalonRepository.GetById(id);

            if (Jalon == null)
            {
                result = NotFound(new { Message = "Project inexistant ou vous n'avez pas le droit d'y accéder!" });
            }
            else
            {
                Project Project = ProjectRepository.GetById(Jalon.ProjectId);
                //on vérifie que l'utilisateur peut effectuvé l'action

                if (!this.Access(Project.Id))
                {
                    result = Unauthorized(new { Message = "Project inexistant ou vous n'avez pas le droit d'y accéder!" });
                }
                else
                {
                    result = Ok(this.TaskRepository.GetTaskForJalon(id));
                }
            }


            return(result);
        }
Esempio n. 5
0
        public IActionResult Get(int id)
        {
            IActionResult result;
            Jalon         Jalon = JalonRepository.GetById(id);

            if (Jalon != null)
            {
                Project Project = ProjectRepository.GetById(Jalon.ProjectId);
                //on vérifie que l'utilisateur n'est pas un chef et que le projet lui est bien assigné avant de lui transmettre l'exigence
                if (!this.Access(Project.Id))
                {
                    result = NotFound(new { Message = "Vous n'avez pas le droit d'accéder à la ressource demander!" });
                }
                else
                {
                    result = Ok(Jalon);
                }
            }
            else
            {
                result = NotFound(new { Message = "Exigence inexistante!" });
            }


            return(result);
        }
Esempio n. 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Jalon jalon = db.Jalon.Find(id);

            db.Jalon.Remove(jalon);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public Jalon GetJalonById(int p_id)
        {
            db_GestionProjetDataSet.JalonRow jr = new JalonTableAdapter().GetById(p_id)[0];

            Jalon v_jalon = FEsimedServiceDA.CreateRowServiceDA().FromDBToBean <Jalon>(jr);

            return(v_jalon);
        }
        public ActionResult Edit(int id)
        {
            Jalon jalon = FactoryServices.createServices().getJalonById(id);
            List <Utilisateur> utilisateurs = FactoryServices.createServices().getUtilisateurs();

            ViewBag.Utilisateurs = utilisateurs;
            return(View("Edit"));
        }
Esempio n. 9
0
 public Jalon updateJalon(int id, string libelle, DateTime date_livraison, DateTime date_reelle, int id_projet, int id_responsable)
 {
     using (JalonTableAdapter jalonTableAdapter = new JalonTableAdapter())
     {
         jalonTableAdapter.updateJalon(id, libelle, date_livraison, date_reelle, id_projet, id_responsable);
         Jalon jalon = new Jalon(id, libelle, date_livraison, id_projet, id_responsable);
         return(jalon);
     }
 }
Esempio n. 10
0
        public Jalon GetJalonSelected()
        {
            Jalon v_jalon = null;

            if (dgvJalon.CurrentRow.DataBoundItem != null)
            {
                v_jalon = (Jalon)dgvJalon.CurrentRow.DataBoundItem;
            }
            return(v_jalon);
        }
Esempio n. 11
0
        public Jalon GetJalonById(int p_id)
        {
            Jalon jalon = null;

            foreach (DataSet.JalonRow row in new JalonTableAdapter().GetJalonById(p_id))
            {
                jalon = FromDBToBean(row);
            }
            return(jalon);
        }
Esempio n. 12
0
 public ActionResult Edit([Bind(Include = "id,id_projet,id_responsable,date_prevue,date_livraison")] Jalon jalon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jalon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_projet      = new SelectList(db.Projet, "id", "nom", jalon.id_projet);
     ViewBag.id_responsable = new SelectList(db.Responsable, "id", "nom", jalon.id_responsable);
     return(View(jalon));
 }
Esempio n. 13
0
        public Jalon getJalonById(int id)
        {
            JalonDataTable jalonDataTable = new JalonDataTable();

            using (JalonTableAdapter jalonTableAdapter = new JalonTableAdapter())
            {
                jalonDataTable = jalonTableAdapter.getJalonById(id);
                JalonRow row   = jalonDataTable[0];
                Jalon    jalon = new Jalon(row.id, row.libelle, row.date_livraison, row.id_projet, row.id_responsable);
                return(jalon);
            }
        }
Esempio n. 14
0
        private void LoadData()
        {
            //Chargement liste responsable
            ctrlListeUser1.Initialiser();

            if (modif)
            {
                Jalon jalonmodif = FEsimedService.CreateJalonService().GetJalonById(id);
                tbLibelle.Text     = jalonmodif.Libelle;
                dtpLivrPrevu.Value = jalonmodif.LivraisonPrevu;
                ctrlListeUser1.SetUserSelected(jalonmodif.IdResp);
            }
        }
Esempio n. 15
0
        // GET: Jalons/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jalon jalon = db.Jalon.Find(id);

            if (jalon == null)
            {
                return(HttpNotFound());
            }
            return(View(jalon));
        }
Esempio n. 16
0
        public static bool isComplete(int id)
        {
            tities db    = new tities();
            Jalon  jalon = db.Jalon.Find(id);

            foreach (Tache tache in jalon.Tache)
            {
                if (!TachesController.isComplete(tache.id))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 17
0
        // GET: Jalons/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jalon jalon = db.Jalon.Find(id);

            if (jalon == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_projet      = new SelectList(db.Projet, "id", "nom", jalon.id_projet);
            ViewBag.id_responsable = new SelectList(db.Responsable, "id", "nom", jalon.id_responsable);
            return(View(jalon));
        }
Esempio n. 18
0
        public IActionResult Update(long id, Jalon item)
        {
            var jalon = _context.jalon.Find(id);

            if (jalon == null)
            {
                return(NotFound());
            }

            jalon.ProjetiD = item.ProjetiD;
            jalon.nom      = item.nom;


            _context.jalon.Update(jalon);
            _context.SaveChanges();
            return(NoContent());
        }
Esempio n. 19
0
        public List <Jalon> getJalonsByProjet(int id_projet)
        {
            JalonDataTable jalonDataTable = new JalonDataTable();
            List <Jalon>   jalons         = new List <Jalon>();

            using (JalonTableAdapter jalonTableAdapter = new JalonTableAdapter())
            {
                jalonDataTable = jalonTableAdapter.getJalonsByProjet(id_projet);
                foreach (JalonRow row in jalonDataTable)
                {
                    Jalon jalon = new Jalon(row.id, row.libelle, row.date_livraison, row.id_projet, row.id_responsable);
                    jalon.Etat = FactoryServicesDA.createTacheServices().getEtatTachesByJalon(row.id);
                    jalons.Add(jalon);
                }
                return(jalons);
            }
        }
Esempio n. 20
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Jalon = await _context.jalon
                    .Include(j => j.Projet)
                    .Include(j => j.Resp).FirstOrDefaultAsync(m => m.JalonID == id);

            if (Jalon == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 21
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Jalon = await _context.jalon.FindAsync(id);

            if (Jalon != null)
            {
                _context.jalon.Remove(Jalon);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index", new{ id = Jalon.ProjetiD }));
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            int id_projet = Convert.ToInt32(Session["projet"]);

            if (ModelState.IsValid)
            {
                string libelle = collection["libelle"];
                int    id_responsable;

                DateTime date_livraison = Convert.ToDateTime(collection["date_livraison"]);
                if (collection.Get("ids_users") == "" || collection.Get("ids_users") == null)
                {
                    string      user_trigramme = collection["user_tri"];
                    Utilisateur utilisateur    = FactoryServices.createServices().insertUtilisateur(user_trigramme);
                    id_responsable = utilisateur.Id;
                }
                else
                {
                    id_responsable = Convert.ToInt32(collection.Get("ids_users"));
                }

                DateTime date_reelle;
                if (collection.Get("date_reelle") == "" || collection.Get("date_reelle") == null)
                {
                    date_reelle = Convert.ToDateTime("");
                }
                else
                {
                    date_reelle = Convert.ToDateTime(collection.Get("date_reelle"));
                }
                Jalon jalon = FactoryServices.createServices().updateJalon(id, libelle, date_livraison, date_reelle, id_projet, id_responsable);
                if (jalon.Id != 0)
                {
                    TempData["alert"]  = "succes";
                    TempData["result"] = "Jalon a été modifé";
                    //return RedirectToAction("Index", "Jalon");
                }
                else
                {
                    TempData["alert"]  = "danger";
                    TempData["result"] = "Une erreur est survenue lors de modification";
                }
            }
            return(RedirectToAction("Index", "Jalon", new { @id = id_projet }));
        }
        private int GetProjectId(int idJalon)
        {
            Jalon Jalon  = JalonRepository.GetById(idJalon);
            int   result = 0;

            if (Jalon != null)
            {
                Project Project = ProjectRepository.GetById(Jalon.ProjectId);
                if (Project != null)
                {
                    result = Project.Id;
                    ProjectRepository.Detach(Project);
                }
            }
            JalonRepository.Detach(Jalon);

            return(result);
        }
Esempio n. 24
0
        protected bool Access(int idProject)
        {
            Project Project = ProjectRepository.GetById(idProject);
            int     userId  = this.GetId();
            bool    result  = true;

            if (Project == null)
            {
                result = false;
            }
            else
            {
                if (Project.Id != userId && !this.IsChief())
                {
                    Jalon Jalon = JalonRepository.getForUser(idProject, userId);
                    if (Jalon == null)
                    {
                        bool         trouver = false;
                        List <Jalon> Jalons  = JalonRepository.GetJalonForProject(idProject);
                        foreach (Jalon aJalon in Jalons)
                        {
                            Task task = TaskRepository.getTaskForUser(aJalon.Id, userId);
                            if (task != null)
                            {
                                trouver = true;
                            }

                            TaskRepository.Detach(task);
                            JalonRepository.Detach(aJalon);
                        }

                        if (!trouver)
                        {
                            result = false;
                        }
                    }
                }

                ProjectRepository.Detach(Project);
            }

            return(result);
        }
Esempio n. 25
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Jalon = await _context.jalon
                    .Include(j => j.Projet)
                    .Include(j => j.Resp).FirstOrDefaultAsync(m => m.JalonID == id);

            if (Jalon == null)
            {
                return(NotFound());
            }
            ViewData["ProjetiD"] = new SelectList(_context.Projets, "ProjetID", "nom");
            ViewData["RespID"]   = new SelectList(_context.resp, "RespID", "nom");
            return(Page());
        }
Esempio n. 26
0
        public IActionResult JalonLivraison([FromBody] Jalon Jalon)
        {
            IActionResult result;
            Project       Project = ProjectRepository.GetById(Jalon.ProjectId);

            if (Project != null)
            {
                if (!this.Access(Project.Id))
                {
                    result = Unauthorized(new { Message = "Vous n'avez pas le droit d'accéder à la ressource demander!" });
                }
                else
                {
                    Jalon UpdateJalon = this.JalonRepository.GetById(Jalon.Id);
                    if (UpdateJalon == null)
                    {
                        result = NotFound(new { Message = "Le jalon n'existe pas" });
                    }
                    else
                    {
                        try
                        {
                            this.JalonRepository.Detach(UpdateJalon);
                            this.ProjectRepository.Detach(Project);
                            Jalon.DateLivReel = DateTime.Now;
                            this.JalonRepository.Update(Jalon);
                            this.JalonRepository.SaveChanges();
                            result = Ok(new { Message = "Livraison effectué" });
                        }
                        catch
                        {
                            result = StatusCode(500);
                        }
                    }
                }
            }
            else
            {
                result = NotFound(new { Message = "Le projet n'éxiste pas" });
            }
            return(result);
        }
Esempio n. 27
0
        public IActionResult UpdateJalon([FromBody] Jalon Jalon)
        {
            IActionResult result;
            Project       Project = ProjectRepository.GetById(Jalon.ProjectId);

            if (Project != null)
            {
                if (this.GetId() != Project.UserId && !this.IsChief())
                {
                    result = Unauthorized(new { Message = "Vous n'avez pas le droit d'accéder à la ressource demander!" });
                }
                else
                {
                    Jalon UpdateJalon = this.JalonRepository.GetById(Jalon.Id);
                    if (UpdateJalon == null)
                    {
                        result = NotFound(new { Message = "Le jalon n'existe pas" });
                    }
                    else
                    {
                        try
                        {
                            this.JalonRepository.Detach(UpdateJalon);
                            this.ProjectRepository.Detach(Project);
                            this.JalonRepository.Update(Jalon);
                            this.JalonRepository.SaveChanges();
                            result = Ok(new { Message = "Modification effectué" });
                        }
                        catch
                        {
                            result = StatusCode(500);
                        }
                    }
                }
            }
            else
            {
                result = NotFound(new { Message = "Le projet n'éxiste pas" });
            }
            return(result);
        }
Esempio n. 28
0
        public Tache getTacheById(int id)
        {
            TacheDataTable tacheDataTable = new TacheDataTable();

            using (TacheTableAdapter tacheTableAdapter = new TacheTableAdapter())
            {
                tacheDataTable = tacheTableAdapter.getTacheById(id);
                TacheRow row   = tacheDataTable[0];
                Tache    tache = new Tache(row.id, row.libelle, row.description, row.date_debut, row.duree, row.id_tache_precente, row.id_responsable, row.id_jalon, row.avancement);
                if (row.id_tache_precente > 0)
                {
                    Tache tache_precedente = FactoryServicesDA.createTacheServices().getTacheById(row.id_tache_precente);
                    tache.Tache_precedente = tache_precedente;
                }
                Utilisateur responsable = FactoryServicesDA.createUtilisateurServices().getUtilisateurById(row.id_responsable);
                tache.Responsable = responsable;
                Jalon jalon = FactoryServicesDA.createJalonServices().getJalonById(row.id_jalon);
                tache.Jalon = jalon;
                return(tache);
            }
        }
Esempio n. 29
0
 public void UpdateJalon(Jalon p_jalon)
 {
     new JalonTableAdapter().UpdateJalon(p_jalon.Nom, p_jalon.Responsable, p_jalon.DateLivraisonPrevue, p_jalon.DateLivraisonReelle, p_jalon.Projet, p_jalon.Id);
 }
Esempio n. 30
0
        public Jalon updateJalon(int id, string libelle, DateTime date_livraison, DateTime date_reelle, int id_projet, int id_responsable)
        {
            Jalon jalon = FactoryServicesDA.createJalonServices().updateJalon(id, libelle, date_livraison, date_reelle, id_projet, id_responsable);

            return(jalon);
        }