public List <Project> GetAllProject() { using (var ctx = new LnkdDataModel()) { return(ctx.Projects.Include("ProjectChief").ToList()); } }
public User Login(User user) { try { using (var ctx = new LnkdDataModel()) { User usr = ctx.Users.FirstOrDefault(x => x.Username == user.Username); if (usr == null) { throw new WebFaultException <string>("Utilisateur introuvable.", System.Net.HttpStatusCode.BadRequest); } else { if (usr.Password != user.Password) { throw new WebFaultException <string>("Wrong Password.", System.Net.HttpStatusCode.BadRequest); } } return(usr); } } catch (Exception ex) { throw new WebFaultException <string>("Server Error : Cannot access database.\n" + ex.Message, System.Net.HttpStatusCode.InternalServerError); } }
public List <Profile> GetProposedProfilesLinkedToProject(string id) { using (var ctx = new LnkdDataModel()) { int ID = Int32.Parse(id); ctx.Projects.Include("ProjectChief").ToList(); return(null); } }
public Project CreateProject(Project project) { using (var ctx = new LnkdDataModel()) { project.ProjectChief = (ProjectChiefProfile)ctx.Profiles.Find(project.ProjectChief.Id); ctx.Projects.Add(project); ctx.SaveChanges(); return(project); } }
public string Get(string id) { using (var ctx = new LnkdDataModel()) { int pId = int.Parse(id); Profile profil = ctx.Profiles.Where(x => x.Id == pId).FirstOrDefault(); if (profil == null) { throw new WebFaultException <string>("Profil not found.", System.Net.HttpStatusCode.BadRequest); } return(JsonConvert.SerializeObject(profil)); } }
public Project GetProject(string id) { using (var ctx = new LnkdDataModel()) { //Project project = ctx.Projects.Find(Int32.Parse(id)); int ID = Int32.Parse(id); Project project = ctx.Projects.Include("ProjectChief").Where(b => b.ID == ID).First(); if (project == null) { throw new WebFaultException <string>("Projet introuvable", System.Net.HttpStatusCode.BadRequest); } return(project); } }
static void Main(string[] args) { //using (var db = new LnkdDataModel()) //{ // Console.WriteLine("--- Creating a new User ---"); // Console.Write("- Username : "******"- Password : "******"DB Saved successfully !"); //} //Console.WriteLine("Press any key to exit ..."); //Console.ReadKey(); using (var ctx = new LnkdDataModel()) { DevelopperProfile pr = new DevelopperProfile() { FirstName = "DevProfil", LastName = "DevProfil", }; ctx.DevelopperProfiles.Add(pr); ProjectChiefProfile pc = new ProjectChiefProfile() { FirstName = "ProjectChiefProfil", LastName = "ProjectChiefProfil", }; ctx.ProjectChiefProfiles.Add(pc); Project p = new Project() { Name = "Projet A", ProjectChief = pc }; p.ProposedProfiles.Add(pr); p.ProposedProfiles.Add(pc); ctx.Projects.Add(p); ctx.SaveChanges(); } System.ServiceModel.ServiceHost loginServiceHost = new System.ServiceModel.ServiceHost(typeof(LoginService)); loginServiceHost.Open(); Console.WriteLine("Login Service Started..."); System.ServiceModel.ServiceHost profileServiceHost = new System.ServiceModel.ServiceHost(typeof(ProfilService)); profileServiceHost.Open(); Console.WriteLine("Profile Service Started..."); System.ServiceModel.ServiceHost projectServiceHost = new System.ServiceModel.ServiceHost(typeof(ProjectService)); projectServiceHost.Open(); Console.WriteLine("Project Service Started..."); Console.ReadKey(); loginServiceHost.Close(); profileServiceHost.Close(); Console.WriteLine("Service(s) closed."); }