public IActionResult Get(int id)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         StrategyModel Objet = repo.GetOne(id)?.ToModel();
         if (Objet == null)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(Objet)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
Ejemplo n.º 2
0
 public static FavoriteStrategyModel ToModel(this FavoriteStrategyEntity FE)
 {
     if (FE != null)
     {
         StrategyRepository    repoEnre = new StrategyRepository();
         UserRepository        repoUtil = new UserRepository();
         FavoriteStrategyModel FM       = new FavoriteStrategyModel();
         FM.Strategy = repoEnre.GetOne(FE.StrategyId).ToModel();
         FM.User     = repoUtil.GetOne(FE.UserId).MapTo <UserModel>();
         FM.Id       = FE.Id;
         FM.Active   = FE.Active;
         return(FM);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
 public static VoteModel ToModel(this VoteEntity VE)
 {
     if (VE != null)
     {
         StrategyRepository repoStr  = new StrategyRepository();
         UserRepository     repoUtil = new UserRepository();
         VoteModel          VM       = new VoteModel();
         VM.Strategy = repoStr.GetOne(VE.StrategyId).ToModel();
         VM.Id       = VE.Id;
         VM.User     = repoUtil.GetOne(VE.UserId).MapTo <UserModel>();
         VM.Vote     = VE.Vote;
         VM.Active   = VE.Active;
         return(VM);
     }
     else
     {
         return(null);
     }
 }