示例#1
0
        // Landing page of the side
        public IActionResult Index()
        {
            APIClient client = new APIClient();
            // pull list of students to display
            APIResponse    response   = client.CallAPI("GET", "/api/students");
            List <int>     studentIds = JsonConvert.DeserializeObject <List <int> >(response.Content);
            List <Student> students   = new List <Student>();

            foreach (int studentId in studentIds)
            {
                // pull student for student id
                response = client.CallAPI("GET", "/api/student/portfolio/" + studentId);
                Student student = JsonConvert.DeserializeObject <Student>(response.Content);
                students.Add(student);

                //clamp description down for rendering in small view
                int clampLimit = 200;
                if (student.Description.Count() > clampLimit)
                {
                    student.Description =
                        student.Description.Substring(0, clampLimit) + " ...";
                }
            }

            return(View(students));
        }
示例#2
0
        public void TestCallAPI()
        {
            // load environment
            DotNetEnv.Env.Load();
            APIClient apiClient = new APIClient();

            // make get students api call
            APIResponse response = apiClient.CallAPI("GET", "/api/students");

            Assert.Equal(200, response.StatusCode);
            Console.WriteLine("Test APIClient: TestCallAPI: got response for students: "
                              + response.Content);

            // make login api call
            string credientialsJson =
                "{ 'EmailAddr': '*****@*****.**', 'Password': '******' }";
            StringContent content = new StringContent(
                credientialsJson, Encoding.UTF8, "application/json");

            response = apiClient.CallAPI("POST", "/api/auth/login",
                                         content);
            Assert.Equal(200, response.StatusCode);
            Console.WriteLine("Test APIClient: TestCallAPI: got response for login: "
                              + response.Content);
        }
        public ActionResult Delete(int id)
        {
            APIClient   api      = new APIClient(HttpContext);
            APIResponse response = api.CallAPI("POST", "/api/lecturer/delete/" + id);

            return(RedirectToAction("Index", "Home"));
        }
        //GET: Lecturer/ChangePassword/5
        public ActionResult ChangePassword(int id)
        {
            APIClient   api      = new APIClient(HttpContext);
            APIResponse response = api.CallAPI("GET", "/api/lecturer/" + id);
            Lecturer    lecturer = JsonConvert.DeserializeObject <Lecturer>(response.Content);

            return(View(lecturer));
        }
示例#5
0
        public ActionResult ViewProjMember(int id)
        {
            APIClient            api               = new APIClient(HttpContext);
            APIResponse          response          = api.CallAPI("GET", "/api/project/member/" + id);
            List <ProjectMember> projectMemberList = JsonConvert.DeserializeObject <List <ProjectMember> >(response.Content);

            return(View(projectMemberList));
        }
        // GET: Lecturer/ViewMentees/5
        public ActionResult ViewMentees(int id)
        {
            APIClient      api      = new APIClient(HttpContext);
            APIResponse    response = api.CallAPI("GET", "/api/lecturer/mentees/" + id);
            List <Student> lecturer = JsonConvert.DeserializeObject <List <Student> >(response.Content);

            return(View(lecturer));
        }
        // GET: Lecturer/UploadPhoto/5
        public ActionResult UploadPhoto(int id)
        {
            APIClient         api      = new APIClient(HttpContext);
            APIResponse       response = api.CallAPI("GET", "/api/lecturer/" + id);
            LecturerViewModel lecturer = JsonConvert.DeserializeObject <LecturerViewModel>(response.Content);

            return(View(lecturer));
        }
        public ActionResult Search(int id)
        {
            APIClient api = new APIClient(HttpContext);

            APIResponse response = api.CallAPI("GET", "/api/skillset/" + id);
            SkillSet    skillSet = JsonConvert.DeserializeObject <SkillSet>(response.Content);

            response = api.CallAPI("GET", "/api/students?skillset=" + id);
            List <int>            studentIds = JsonConvert.DeserializeObject <List <int> >(response.Content);
            IEnumerable <Student> students   = studentIds.Select((studentId) => {
                response = api.CallAPI("GET", "/api/student/" + studentId);
                return(JsonConvert.DeserializeObject <Student>(response.Content));
            });

            ViewData["Students"] = students;

            return(View(skillSet));
        }
        // GET: Suggestion/Details/5
        public ActionResult Details(int id)
        {
            APIClient         api            = new APIClient(HttpContext);
            APIResponse       response       = api.CallAPI("GET", "/api/suggestion/student/" + id);
            List <Suggestion> suggestionList = JsonConvert.DeserializeObject <List <Suggestion> >(response.Content);

            ViewData["studentId"] = id;
            return(View(suggestionList));
        }
        public ActionResult Delete(int id)
        {
            APIClient client       = new APIClient(HttpContext);
            string    skillSetJson = JsonConvert.SerializeObject(id);

            APIResponse response = client.CallAPI("POST", "/api/skillset/delete/" + id,
                                                  new StringContent(skillSetJson, Encoding.UTF8, "application/json"));

            return(View());
        }
示例#11
0
        // GET: /<controller>/
        public async Task <ActionResult> Index(int id)

        {
            APIClient api = new APIClient();

            APIResponse response = api.CallAPI("GET", "/api/project/" + id);
            Project     project  = JsonConvert.DeserializeObject <Project>(response.Content);

            response = api.CallAPI("GET", "/api/projects?student=" + id);
            List <int>            studentIds = JsonConvert.DeserializeObject <List <int> >(response.Content);
            IEnumerable <Project> students   = studentIds.Select((studentId) => {
                response = api.CallAPI("GET", "/api/project/" + studentId);
                return(JsonConvert.DeserializeObject <Project>(response.Content));
            });

            ViewData["Projects"] = students;

            return(View(project));
        }
示例#12
0
        public async Task <ActionResult> ViewProjMember(int id, ProjectMember projMember, int student)
        {
            APIClient   client      = new APIClient(HttpContext);
            string      projectJson = JsonConvert.SerializeObject(projMember);
            APIResponse response    = client.CallAPI("POST", "/api/project/assign/" + id + "?student=" + student);

            new StringContent(projectJson, Encoding.UTF8, "application/json");

            return(View(projMember));
        }
示例#13
0
        public async Task <ActionResult> Create(int id, Project project, IFormCollection collection)
        {
            APIClient client      = new APIClient(HttpContext);
            string    projectJson = JsonConvert.SerializeObject(project);

            APIResponse response = client.CallAPI("POST", "/api/project/create",
                                                  new StringContent(projectJson, Encoding.UTF8, "application/json"));
            Dictionary <string, int> reciept = JsonConvert.DeserializeObject <Dictionary <string, int> >(response.Content);
            int projectId = reciept["projectId"];

            if (response.StatusCode == 200)
            {
                // assign creator to project
                UserInfo creator = HttpContext.Items["UserInfo"] as UserInfo;
                response = client.CallAPI("POST", "/api/project/assign/" + projectId + "?student=" + creator.Id);
                Console.WriteLine(">>>>>>>" + response.StatusCode);
            }
            return(View(project));
        }
        public ActionResult SignUp(Lecturer lecturer)
        {
            var    content     = JsonConvert.SerializeObject(lecturer);
            string contentType = "application/json";
            var    sContent    = new StringContent(content, Encoding.UTF8, contentType);

            APIClient   api      = new APIClient(HttpContext);
            APIResponse response = api.CallAPI("POST", "/api/lecturer/create", sContent);

            return(RedirectToAction("Login", "Auth"));
        }
        public ActionResult ChangePassword(int id, Lecturer lecturer)
        {
            var    content     = JsonConvert.SerializeObject(lecturer);
            string contentType = "application/json";
            var    sContent    = new StringContent(content, Encoding.UTF8, contentType);

            APIClient   api      = new APIClient(HttpContext);
            APIResponse response = api.CallAPI("POST", "/api/lecturer/changePW/" + id, sContent);

            return(RedirectToAction("Index"));
        }
        public ActionResult Portfolio(int id)
        {
            APIClient api = new APIClient(HttpContext);

            // pull student portfolio data for id
            APIResponse response = api.CallAPI("GET", "/api/student/portfolio/" + id);
            Student     student  = JsonConvert.DeserializeObject <Student>(response.Content);

            // pull student projects
            response = api.CallAPI("GET", "/api/projects?student=" + id);
            List <int>            projectIds = JsonConvert.DeserializeObject <List <int> >(response.Content);
            IEnumerable <Project> projects   = projectIds.Select((projectId) =>
            {
                response        = api.CallAPI("GET", "/api/project/" + projectId);
                Project project = JsonConvert.DeserializeObject <Project>(response.Content);

                //clamp description down for rendering in small view
                int clampLimit = 128;
                if (project.Description.Count() > clampLimit)
                {
                    project.Description =
                        project.Description.Substring(0, clampLimit) + " ...";
                }

                return(project);
            });

            ViewData["Projects"] = projects;

            // pull student's skilsets
            response = api.CallAPI("GET", "/api/skillsets?student=" + id);
            List <int>             skillSetIds = JsonConvert.DeserializeObject <List <int> >(response.Content);
            IEnumerable <SkillSet> skillSets   = skillSetIds.Select((skillSetId) => {
                response = api.CallAPI("GET", "/api/skillset/" + skillSetId);
                return(JsonConvert.DeserializeObject <SkillSet>(response.Content));
            });

            ViewData["SkillSets"] = skillSets;

            return(View(student));
        }
示例#17
0
        public async Task <ActionResult> Edit(int id, Project project, IFormCollection collection)
        {
            APIClient client      = new APIClient(HttpContext);
            string    projectJson = JsonConvert.SerializeObject(project);

            APIResponse response = client.CallAPI("POST", "/api/project/update/" + id,
                                                  new StringContent(projectJson, Encoding.UTF8, "application/json"));



            return(View(project));
        }
        public ActionResult Edit(int id, Lecturer lecturer)
        {
            var    content     = JsonConvert.SerializeObject(lecturer);
            string contentType = "application/json";

            var sContent = new StringContent(content, Encoding.UTF8, contentType);

            APIClient api = new APIClient(HttpContext);

            APIResponse response = api.CallAPI("POST", "/api/lecturer/update/" + id, sContent);

            return(RedirectToAction("Details", new { id = id }));
        }
        public ActionResult Create(Suggestion suggestion)
        {
            var    content     = JsonConvert.SerializeObject(suggestion);
            string contentType = "application/json";

            var sContent = new StringContent(content, Encoding.UTF8, contentType);

            APIClient api = new APIClient(HttpContext);

            APIResponse response = api.CallAPI("POST", "/api/suggestion/create", sContent);

            return(RedirectToAction("Index", "Lecturer"));
        }