示例#1
0
 /// <summary>
 /// Post API/Login
 /// </summary>
 /// <param name="User">User à tester</param>
 public IHttpActionResult Post(UserModel User)
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (User == null || User.Password == null || User.Username == null)
         {
             return(BadRequest());
         }
         else
         {
             if (repo.Check(User.Username, User.Password))
             {
                 UserEntity U     = repo.GetOneByUsername(User.Username);
                 JWTService jwt   = new JWTService("FZeDfgPkyXaDFyMwQfSbIoJhF", "localhost:4200", "localhost:4200");
                 string     token = jwt.Encode(U);
                 return(Ok(token));
             }
             else
             {
                 return(BadRequest());
             }
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#2
0
 /// <summary>
 /// Post API/Login/{Id}/?Token={Token}
 /// </summary>
 /// <param name="User">User à tester</param>
 public IHttpActionResult Post(int Id, [FromBody] string Token)
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Token == null)
         {
             return(BadRequest());
         }
         else
         {
             if (repo.UpdateToken(Id, Token))
             {
                 return(Ok());
             }
             else
             {
                 return(BadRequest());
             }
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult Get()
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <BossesZoneModel> List = repo.GetAll().Select(BossZone => BossZone?.ToModel());
         return(Ok(JsonConvert.SerializeObject(List)));
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult Get()
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <FavoriteStrategyModel> List = repo.GetAll().Select(Favori => Favori?.ToModel());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(List)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult Get(int id)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         FavoriteStrategyModel Objet = repo.GetOne(id)?.ToModel();
         if (Objet == null)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(Objet)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 /// <summary>
 /// Get API/Follow/?FollowerId={FollowerId}&FollowedId={FollowedId}
 /// </summary>
 /// <param name="id">id du Follow à récupérer</param>
 /// <returns>Follow avec l'id correspondant</returns>
 public IHttpActionResult Get([FromUri] int FollowerId, [FromUri] int FollowedId)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         int Id = repo.GetOneByFollowerAndFollowed(FollowerId, FollowedId);
         if (Id == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Json(Id));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult GetByMail(string mail)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         UserModel Objet = repo.GetOneByMail(mail)?.MapTo <UserModel>();
         if (Objet == null)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(Objet)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#8
0
 public IHttpActionResult PostPass([FromUri] int IdUser, [FromBody] string NewPassword)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOne(IdUser) == null || NewPassword == "")
         {
             return(BadRequest());
         }
         else
         {
             repo.UpdatePassword(IdUser, NewPassword);
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult PostPass(string Mail)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOneByMail(Mail) == null || Mail == "")
         {
             return(BadRequest());
         }
         else
         {
             repo.NouveauPassword(Mail);
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult Get(int?U, int?BZ, int?C1, int?C2, int?C3, int?C4)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <StrategyModel> List = repo.GetAllByInfos(U, BZ, C1, C2, C3, C4).Select(Strategy => Strategy.ToModel());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(List)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#11
0
 public IHttpActionResult GetbyUser([FromUri] int UserId)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <VoteModel> List = repo.GetAllbyUserId(UserId).Select(Vote => Vote?.ToModel());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Json(List));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#12
0
 /// <summary>
 /// Get API/Strategy
 /// </summary>
 /// <returns>List de toutes les Strategys</returns>
 public IHttpActionResult Get()
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <StrategyModel> List = repo.GetAll().Select(Strategy => Strategy?.ToModel());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Json(List));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#13
0
 /// <summary>
 /// Post API/Team
 /// </summary>
 /// <param name="E">CharactersConfiguration à insérer</param>
 public IHttpActionResult Post(TeamModel Team)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Team == null || Team.CharactersConfiguration.Id == 0 || Team.Zone.Id == 0 || Team.User.Id == 0 || Team.TeamName == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Team.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#14
0
 public IActionResult Post([FromBody] BossModel Boss)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Boss == null || Boss.NameEN == null || Boss.NameFR == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Boss.MapTo <BossEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#15
0
 public IActionResult Post([FromBody] CharactersConfigurationModel CharactersConfiguration)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (CharactersConfiguration == null || CharactersConfiguration.Classe1.Id == 0 || CharactersConfiguration.Classe2.Id == 0 || CharactersConfiguration.Classe3.Id == 0 || CharactersConfiguration.Classe4.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(CharactersConfiguration.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#16
0
 public IActionResult Get(int C1, int C2, int C3, int C4)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         CharactersConfigurationModel Objet = repo.GetCharactersConfigurationByClasses(C1, C2, C3, C4).ToModel();
         if (Objet == null)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(Objet)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#17
0
 public IActionResult Post([FromBody] ZoneModel Zone)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Zone == null || Zone.ContinentEN == null || Zone.ContinentFR == null || Zone.ZoneEN == null || Zone.ZoneFR == null || Zone.ZoneQty == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Zone.MapTo <ZoneEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult Post([FromBody] StrategyModel Strategy)
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Strategy == null || Strategy.ImagePath1 == null || Strategy.ImagePath2 == null || Strategy.ImagePath3 == null || Strategy.ImagePath4 == null || Strategy.CharactersConfiguration.Id == 0 || Strategy.User.Id == 0 || Strategy.BossZone.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Strategy.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#19
0
 /// <summary>
 /// Post API/Vote
 /// </summary>
 /// <param name="E">Vote à insérer</param>
 public IHttpActionResult Post(VoteModel Vote)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Vote == null || Vote.Strategy.Id == 0 || Vote.User.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Vote.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 public IActionResult Post(SkillModel Skill)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Skill == null || Skill.NameEN == null || Skill.NameFR == null || Skill.Classe.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Skill.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#21
0
 /// <summary>
 /// Post API/Login/?IdU={Id}
 /// </summary>
 /// <param name="User">User à tester</param>
 public IHttpActionResult Post([FromUri] int IdU)
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOne(IdU) == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.RenvoiToken(IdU);
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#22
0
 /// <summary>
 /// Delete API/User/{id}
 /// </summary>
 /// <param name="id">id de l'User à supprimer</param>
 public IHttpActionResult Delete(int id)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOne(id) == null)
         {
             return(NotFound());
         }
         else
         {
             repo.Delete(id);
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#23
0
 public IHttpActionResult PostUsername([FromUri] string MailforUsername)
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOneByMail(MailforUsername) == null || MailforUsername == "")
         {
             return(BadRequest());
         }
         else
         {
             repo.RetrieveUsername(MailforUsername);
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#24
0
 /// <summary>
 /// Get API/User
 /// </summary>
 /// <returns>List de tous les User</returns>
 public IHttpActionResult Get()
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <UserModel> List = repo.GetAllAdmin().Select(User => User?.MapTo <UserModel>());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Json(List));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#25
0
 public IActionResult Get()
 {
     if ((new[] { "Admin", "User", "Anonymous" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <ToyModel> List = repo.GetAll().Select(Toy => Toy?.MapTo <ToyModel>());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(JsonConvert.SerializeObject(List)));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 /// <summary>
 /// Post API/Follow
 /// </summary>
 /// <param name="Follow">Follow à insérer</param>
 public IHttpActionResult Post(FollowModel Follow)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Follow == null || Follow.Followed.Id == 0 || Follow.Follower.Id == 0)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Follow.ToEntity());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#27
0
 /// <summary>
 /// Post API/User
 /// </summary>
 /// <param name="E">User à insérer</param>
 public IHttpActionResult Post(UserModel User)
 {
     if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (User == null || User.Mail == null || User.Password == null || User.Username == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(User.MapTo <UserEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 /// <summary>
 /// Post API/Classe
 /// </summary>
 /// <param name="Classe">Classe à insérer</param>
 public IHttpActionResult Post(ClasseModel Classe)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Classe == null || Classe.NameEN == null || Classe.NameFR == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Classe.MapTo <ClasseEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
示例#29
0
 /// <summary>
 /// Get API/User/{id}
 /// </summary>
 /// <param name="id">id du User à récupérer</param>
 /// <returns>User avec l'id correspondant</returns>
 public IHttpActionResult Get(int id)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         UserModel Objet = repo.GetOne(id)?.MapTo <UserModel>();
         if (Objet == null)
         {
             return(NotFound());
         }
         else
         {
             return(Json(Objet));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
 /// <summary>
 /// Post API/Toy
 /// </summary>
 /// <param name="E">Toy à insérer</param>
 public IHttpActionResult Post(ToyModel Toy)
 {
     if ((new[] { "Admin" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (Toy == null || Toy.ImagePath == null || Toy.NameFR == null || Toy.NameEN == null)
         {
             return(BadRequest());
         }
         else
         {
             repo.Create(Toy.MapTo <ToyEntity>());
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }