Ejemplo n.º 1
0
        public ActionResult AddPost()
        {
            var postTitle = Request["postTitle"];
            var postImg   = Request["postImg"];
            var postFile  = Request["postFile"];
            var postText  = Request["postText"];
            var groupId   = Request["groupId"];


            int id = SessionManager.GetUser().Id;
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("userId", id.ToString());
            headers.Add("userPass", SessionManager.GetUser().Password);
            Post post = new Post()
            {
                Title      = postTitle,
                Content    = postText,
                Picture    = postImg,
                Attachment = postFile,
                GroupId    = int.Parse(groupId),
            };
            String fluxResult = WWWFetcher.Post("http://localhost:8080/api/posts", JsonConvert.SerializeObject(post), headers);

            return(null);
        }
Ejemplo n.º 2
0
        public ActionResult Register(FormCollection form)
        {
            String   firstName = Convert.ToString(form["firstName"]);
            String   lastName  = Convert.ToString(form["lastName"]);
            String   email     = Convert.ToString(form["email"]);
            DateTime brth      = Convert.ToDateTime(form["brth"]);
            String   titre     = Convert.ToString(form["titre"]);
            String   company   = Convert.ToString(form["company"]);
            String   psw       = Convert.ToString(form["psw"]);

            User user = new User()
            {
                Password  = psw,
                FirstName = firstName,
                LastName  = lastName,
                BirthDate = brth,
                Title     = titre,
                Company   = company,
                Mail      = email,
            };



            String result = WWWFetcher.Post("http://localhost:8080/api/users", JsonConvert.SerializeObject(user), null);

            return(RedirectToAction("Index", "LandingPage"));
        }
Ejemplo n.º 3
0
        public ActionResult Connexion(FormCollection form)
        {
            string Email = Convert.ToString(form["email"]);
            string Psw   = Convert.ToString(form["password"]);


            if (Email == null || Psw == null)
            {
                return(View());
            }
            else
            {
                Dictionary <string, string> headers = new Dictionary <string, string>();
                headers.Add("userMail", Email);
                headers.Add("userPass", Psw);
                string result = WWWFetcher.Get("http://localhost:8080/api/users/auth", headers);
                User   user   = JsonConvert.DeserializeObject <User>(result);
                if (user != null)
                {
                    User newUser = new User();
                    newUser.Copy(user);
                    newUser.Id = user.Id;
                    SessionManager.SetUser(newUser);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(RedirectToAction("Connexion", "LandingPage"));
        }
Ejemplo n.º 4
0
        public ActionResult Show(int idGroup)
        {
            string id = SessionManager.GetUser().Id.ToString();
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("userId", id);
            headers.Add("userPass", SessionManager.GetUser().Password);
            String fluxResult = WWWFetcher.Get("http://localhost:8080/api/groups/" + idGroup, headers);
            Group  group      = JsonConvert.DeserializeObject <Group>(fluxResult);

            ViewBag.Group = group;
            return(View());
        }
Ejemplo n.º 5
0
        // GET: Profil
        public ActionResult Index()
        {
            string id = SessionManager.GetUser().Id.ToString();
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("userId", id);
            headers.Add("userPass", SessionManager.GetUser().Password);
            String      groupResult = WWWFetcher.Get("http://localhost:8080/api/users/" + id, headers);
            User        user        = JsonConvert.DeserializeObject <User>(groupResult);
            String      postsResult = WWWFetcher.Get("http://localhost:8080/api/flux/user/" + id, headers);
            List <Post> posts       = JsonConvert.DeserializeObject <List <Post> >(postsResult);

            ViewBag.Groups = user.groups;
            ViewBag.Posts  = posts;
            return(View());
        }
Ejemplo n.º 6
0
        public ActionResult addGroup()
        {
            var name   = Request["groupName"];
            var privat = Request["privacy"] == "private";
            int id     = SessionManager.GetUser().Id;
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("userId", id.ToString());
            headers.Add("userPass", SessionManager.GetUser().Password);
            Group group = new Group()
            {
                Name    = name,
                Private = privat,
                OwnerId = id,
            };
            String fluxResult = WWWFetcher.Post("http://localhost:8080/api/group", JsonConvert.SerializeObject(group), headers);

            return(null);
        }
Ejemplo n.º 7
0
        public ActionResult Index(/*EnvironmentVariableTarget groupName*/)
        {
            if (SessionManager.GetUser() != null)
            {
                int id = SessionManager.GetUser().Id;
                Dictionary <string, string> headers = new Dictionary <string, string>();
                headers.Add("userId", id.ToString());
                headers.Add("userPass", SessionManager.GetUser().Password);
                String      fluxResult = WWWFetcher.Get("http://localhost:8080/api/flux/user/" + id, headers);
                List <Post> posts      = JsonConvert.DeserializeObject <List <Post> >(fluxResult);
                ViewBag.Posts  = posts;
                ViewBag.UserId = id;
                String groupResult = WWWFetcher.Get("http://localhost:8080/api/users/" + id, headers);
                User   user        = JsonConvert.DeserializeObject <User>(groupResult);
                ViewBag.Groups = user.groups;



                return(View());
            }
            return(RedirectToAction("Index", "LandingPage"));
        }