示例#1
0
        public async Task <IActionResult> RefuserNegociation([Bind("Id, DateClotureNegociation, NewDateProposee, HeureDbtProposee, HeurFinProposee, IsAccepted, DateCreationNegociation")] Negociation negocProposee, int Id, int IdMembre, int IdFeat)
        {
            negocProposee = _context.Negociations
                            .Where(b => b.Id == Id)
                            .Include(b => b.feat)
                            .Include(b => b.Demandeur)
                            .Include(b => b.Repondeur)
                            .Include(b => b.feat.Type)
                            .Include(b => b.feat.Createur)
                            .Include(b => b.feat.Materiel)
                            .FirstOrDefault();

            negocProposee.IsAccepted             = false;
            negocProposee.DateClotureNegociation = DateTime.Now;



            if (ModelState.IsValid)
            {
                _context.Update(negocProposee);

                await _context.SaveChangesAsync();


                return(RedirectToAction("MesFeats", "PAFeats", new { @id = IdMembre }));
            }
            return(RedirectToAction("HomeFeatsHome"));
        }
示例#2
0
        public async Task <IActionResult> ModifierMonFeatGiftee([Bind("Id, CreationDate, RealisationDate, HeureDebut, HeureFin, AcceptationDate, EnCoursRealisation, SurPlace, FinFeatHelper, ClotureDate, SommePrevoir, SommeAvancee, SommeRembourseeDate, AnnulationDate, EchangeMonetaire, AideChoisie, Materiel")] Feat featToModify, int JeSuis, int IdMembre)
        {
            Feat oldFeat = GetFeat(featToModify.Id);

            var ReponseValide = _context.ReponseHelpers
                                .Where(b => b.Feat.Id == featToModify.Id)
                                .Where(b => b.DesistementDate == null)
                                .Include(b => b.Helper)
                                .FirstOrDefault();



            Negociation newNegociation = new Negociation();

            if (oldFeat.HeureDebut != featToModify.HeureDebut || oldFeat.HeureFin != featToModify.HeureFin || oldFeat.RealisationDate != featToModify.RealisationDate)
            {
                var newDate     = featToModify.RealisationDate;
                var newHeureDeb = featToModify.HeureDebut;
                var newHeureFin = featToModify.HeureFin;
                featToModify = new Feat();

                newNegociation = new Negociation()
                {
                    DateCreationNegociation = DateTime.Now,
                    NewDateProposee         = newDate,
                    HeureDbtProposee        = newHeureDeb,
                    HeureFinProposee        = newHeureFin,
                    feat       = oldFeat,
                    IsAccepted = false
                };

                if (JeSuis == 1)
                {
                    newNegociation.DemandeurId = oldFeat.Createur.Id;
                    newNegociation.RepondeurId = ReponseValide.Helper.Id;
                }
                else
                {
                    newNegociation.DemandeurId = ReponseValide.Helper.Id;
                    newNegociation.RepondeurId = oldFeat.Createur.Id;
                }
            }

            // _context.Entry(featToModify).Reference(p => p.Createur).Load();

            if (ModelState.IsValid)
            {
                _context.Add(newNegociation);
                await _context.SaveChangesAsync();


                return(RedirectToAction("MesFeats", "PAFeats", new { @id = IdMembre }));
            }
            return(RedirectToAction("HomeFeatsHome"));
        }
示例#3
0
        public async Task <IActionResult> AccepterNegociation([Bind("Id, DateClotureNegociation, NewDateProposee, HeureDbtProposee, HeurFinProposee, IsAccepted, DateCreationNegociation")] Negociation negocProposee, int Id, int IdMembre, int IdFeat)
        {
            negocProposee = _context.Negociations
                            .Where(b => b.Id == Id)
                            .Include(b => b.feat)
                            .Include(b => b.Demandeur)
                            .Include(b => b.Repondeur)
                            .Include(b => b.feat.Type)
                            .Include(b => b.feat.Createur)
                            .Include(b => b.feat.Materiel)
                            .FirstOrDefault();

            Feat featToModify = _context.Feats
                                .Where(b => b.Id == IdFeat)
                                .Include(b => b.Createur)
                                .Include(b => b.Adresse)
                                .Include(b => b.Materiel)
                                .Include(b => b.Type)
                                .FirstOrDefault();

            negocProposee.IsAccepted             = true;
            negocProposee.DateClotureNegociation = DateTime.Now;

            featToModify.RealisationDate = negocProposee.NewDateProposee;
            featToModify.HeureDebut      = negocProposee.HeureDbtProposee;
            featToModify.HeureFin        = negocProposee.HeureFinProposee;


            if (ModelState.IsValid)
            {
                _context.UpdateRange(negocProposee, featToModify);
                _context.SaveChanges();


                return(RedirectToAction("MesFeats", "PAFeats", new { @id = IdMembre }));
            }
            return(RedirectToAction("HomeFeatsHome"));
        }
示例#4
0
        public async Task <IActionResult> VisualiserNegociation(int IdFeat, int IdMembre)
        {
            Negociation negocProposee = _context.Negociations
                                        .Where(b => b.feat.Id == IdFeat)
                                        .Where(b => b.DateClotureNegociation == null)
                                        .Include(b => b.feat)
                                        .Include(b => b.Demandeur)
                                        .Include(b => b.Repondeur)
                                        .Include(b => b.feat.Type)
                                        .Include(b => b.feat.Createur)
                                        .Include(b => b.feat.Materiel)
                                        .FirstOrDefault();

            ViewBag.IdMembre = IdMembre;
            Membre membre = _context.Membres
                            .Where(b => b.Id == IdMembre)
                            .FirstOrDefault();

            ViewBag.PrenomMembre = membre.Prenom;
            ViewBag.NomMembre    = membre.Nom;

            return(View(negocProposee));
        }