public static CharactersConfigurationModel ToModel(this CharactersConfigurationEntity CCE) { if (CCE != null) { ClasseRepository repoCl = new ClasseRepository(); CharactersConfigurationModel CCM = new CharactersConfigurationModel(); CCM.Id = CCE.Id; CCM.Classe1 = repoCl.GetOne(CCE.ClasseId1).MapTo <ClasseModel>(); CCM.Classe2 = repoCl.GetOne(CCE.ClasseId2).MapTo <ClasseModel>(); CCM.Classe3 = repoCl.GetOne(CCE.ClasseId3).MapTo <ClasseModel>(); CCM.Classe4 = repoCl.GetOne(CCE.ClasseId4).MapTo <ClasseModel>(); CCM.Active = CCE.Active; return(CCM); } else { return(null); } }
/// <summary> /// Get API/Classe/{id} /// </summary> /// <param name="id">id de la Classe à récupérer</param> /// <returns>Classe avec l'id correspondant</returns> public IHttpActionResult Get(int id) { if ((new[] { "Admin", "User", "Anonyme" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { ClasseModel Objet = repo.GetOne(id)?.MapTo <ClasseModel>(); if (Objet == null) { return(NotFound()); } else { return(Json(Objet)); } } else { return(Unauthorized()); } }
public static SkillModel ToModel(this SkillEntity SE) { if (SE != null) { ClasseRepository repoCl = new ClasseRepository(); SkillModel SM = new SkillModel(); SM.Id = SE.Id; SM.NameEN = SE.NameEN; SM.NameFR = SE.NameFR; SM.DescriptionEN = SE.DescriptionEN; SM.DescriptionFR = SE.DescriptionFR; SM.Location = SE.Location; SM.Cost = SE.Cost; SM.ImagePath = SE.ImagePath; SM.Classe = repoCl.GetOne(SE.ClasseId).MapTo <ClasseModel>(); SM.Active = SE.Active; return(SM); } else { return(null); } }