Exemplo n.º 1
0
 public List <Project> GetAllProject()
 {
     using (var ctx = new LnkdDataModel())
     {
         return(ctx.Projects.Include("ProjectChief").ToList());
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public List <Profile> GetProposedProfilesLinkedToProject(string id)
        {
            using (var ctx = new LnkdDataModel())
            {
                int ID = Int32.Parse(id);

                ctx.Projects.Include("ProjectChief").ToList();
                return(null);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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.");
        }