public void InsertOpportunite(Opportunite Opportunite)
 {
     if (Opportunite != null)
     {
         Projet p = _dbContext.Projets.Where(A => A.Id == Opportunite.Id).FirstOrDefault();
         p.Opportunites.Add(Opportunite);
         Save();
     }
 }
Example #2
0
 public IActionResult Post([FromBody] Opportunite opportunite)
 {
     using (var scope = new TransactionScope())
     {
         _opportuniteRepository.InsertOpportunite(opportunite);
         scope.Complete();
         return(CreatedAtAction(nameof(Get), new { id = opportunite.Id }, opportunite));
     }
 }
Example #3
0
 public IActionResult Put([FromBody] Opportunite Model)
 {
     if (Model != null)
     {
         using (var scope = new TransactionScope())
         {
             _opportuniteRepository.UpdateOpportunite(Model);
             scope.Complete();
             return(new OkResult());
         }
     }
     return(new NoContentResult());
 }
Example #4
0
 public void InsertEvaluation(Evaluation Evaluation)
 {
     if (Evaluation != null)
     {
         if (Evaluation.OpportuniteId != null)
         {
             Opportunite opportunite = _dbContext.Opportunites.Where(A => A.Id == Evaluation.OpportuniteId).FirstOrDefault();
             opportunite.Evaluations.Add(Evaluation);
             Save();
         }
         else if (Evaluation.RisqueId != null)
         {
             Risque risque = _dbContext.Risques.Where(A => A.Id == Evaluation.RisqueId).FirstOrDefault();
             risque.Evaluations.Add(Evaluation);
             Save();
         }
     }
 }
 public void UpdateOpportunite(Opportunite Opportunite)
 {
     _dbContext.Entry(Opportunite).State = EntityState.Modified;
     Save();
 }
 protected override Task HandleRequirementAsync(AuthorizationHandlerContext context,
                                                SameUserRequirement requirement,
                                                object resource)
 {
     if (resource.GetType() == typeof(Projet))
     {
         Projet model  = (Projet)resource;
         Projet Projet = _projetRepository.GetProjetByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Document))
     {
         Document d        = (Document)resource;
         Document document = _documentRepository.GetDocumentByID(d.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == document.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Phase))
     {
         Phase model = (Phase)resource;
         Phase Phase = _phaseRepository.GetPhaseByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Phase.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Models.Action))
     {
         Models.Action model  = (Models.Action)resource;
         Models.Action Action = _actionRepository.GetActionByID(model.Id);
         if (Action.ProjetId != null)
         {
             if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Action.Projet.UserId)
             {
                 context.Succeed(requirement);
             }
         }
         else
         {
             if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Action.Phase.Projet.UserId)
             {
                 context.Succeed(requirement);
             }
         }
     }
     else if (resource.GetType() == typeof(Tache))
     {
         Tache model = (Tache)resource;
         Tache Tache = _tacheRepository.GetTacheByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Tache.Action.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Reunion))
     {
         Reunion model   = (Reunion)resource;
         Reunion Reunion = _reunionRepository.GetReunionByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Reunion.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Objectif))
     {
         Objectif model    = (Objectif)resource;
         Objectif Objectif = _objectifRepository.GetObjectifByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Objectif.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Risque))
     {
         Risque model  = (Risque)resource;
         Risque Risque = _risqueRepository.GetRisqueByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Risque.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Opportunite))
     {
         Opportunite model       = (Opportunite)resource;
         Opportunite Opportunite = _opportuniteRepository.GetOpportuniteByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Opportunite.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Indicateur))
     {
         Indicateur model      = (Indicateur)resource;
         Indicateur Indicateur = _indicateurRepository.GetIndicateurByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Indicateur.Objectif.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Mesure))
     {
         Mesure model  = (Mesure)resource;
         Mesure Mesure = _mesureRepository.GetMesureByID(model.Id);
         if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Mesure.Indicateur.Objectif.Projet.UserId)
         {
             context.Succeed(requirement);
         }
     }
     else if (resource.GetType() == typeof(Evaluation))
     {
         Evaluation model      = (Evaluation)resource;
         Evaluation Evaluation = _evaluationRepository.GetEvaluationByID(model.Id);
         if (Evaluation.OpportuniteId != null)
         {
             if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Evaluation.Opportunite.Projet.UserId)
             {
                 context.Succeed(requirement);
             }
         }
         else
         {
             if (new Guid(context.User.FindFirstValue(ClaimTypes.NameIdentifier)) == Evaluation.Risque.Projet.UserId)
             {
                 context.Succeed(requirement);
             }
         }
     }
     return(Task.CompletedTask);
 }