public Response PutPerson([FromBody] Person person)
        {
            Response response    = new Response();
            String   mlResponse  = MarkLogicLayer.putPerson(person);
            JObject  jsonPayload = JObject.FromObject(person);

            response.payload = jsonPayload;
            return(response);
        }
Ejemplo n.º 2
0
        // public void queryEvent(string eid)
        //{
        //    MarkLogicLayer.getEventMLById(eid);
        //}

        public Response PutEvent([FromBody] Event eventToPut)
        {
            Response response    = new Response();
            String   mlResponse  = MarkLogicLayer.putEvent(eventToPut);
            JObject  jsonPayload = JObject.FromObject(eventToPut);

            response.payload = jsonPayload;
            return(response);
        }
        public Response GetRecommendation()
        {
            String pid = HttpContext.Current.Request.QueryString["pid"];
            //String pid = Request.QueryString["pid"];  // personId
            Response response = new Response();

            Event[] recommendedEvent = JsonConvert.DeserializeObject <Event[]>(MarkLogicLayer.getRecommendedEventFromPersonId(pid).ToString());

            JArray jsonPayload = JArray.FromObject(recommendedEvent);

            response.payload = jsonPayload;
            return(response);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get one event with event name in JSON format
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Response GetEvent(string eid)
        {
            Response response = new Response();
            var      _event   = MarkLogicLayer.getEventMLById(eid);

            //var _event = events.FirstOrDefault((p)=> p.EventName == name);

            if (_event == null)
            {
                response.errorCode = 404;
                response.errorText = "EVENT_NOT_FOUND";
            }
            else
            {
                response.payload = _event;
            }

            return(response);
        }
        public Response getPerson(string pid)
        {
            Response response = new Response();
            var      person   = MarkLogicLayer.getPersonMLById(pid);

            //var _event = events.FirstOrDefault((p)=> p.EventName == name);

            if (person == null)
            {
                response.errorCode = 404;
                response.errorText = "EVENT_NOT_FOUND";
            }
            else
            {
                response.payload = person;
            }

            return(response);
        }
Ejemplo n.º 6
0
        public Response registerAttendance([FromBody] dynamic values)
        {
            /* {
             *  "pid" : "" , "eid" : ""
             * } */

            String   pid      = values.pid; // personId
            String   eid      = values.eid; // eventId
            Response response = new Response();
            //JObject eventJson = MarkLogicLayer.getEventMLById(eid);

            Event         eventObject = JsonConvert.DeserializeObject <Event>(MarkLogicLayer.getEventMLById(eid).ToString());
            List <string> attendees   = eventObject.Attendees.ToList();

            if (!attendees.Contains(pid))
            {
                attendees.Add(pid);
            }
            eventObject.Attendees = attendees.ToArray();
            MarkLogicLayer.putEvent(eventObject);

            Person        personObject = JsonConvert.DeserializeObject <Person>(MarkLogicLayer.getPersonMLById(pid).ToString());
            List <string> eventList    = personObject.EventList.ToList();

            if (!eventList.Contains(eid))
            {
                eventList.Add(eid);
            }
            personObject.EventList = eventList.ToArray();
            MarkLogicLayer.putPerson(personObject);

            JObject jsonPayload = JObject.FromObject(eventObject);

            response.payload = jsonPayload;
            return(response);
        }
        //
        // GET: /SignIn-LinkedIn/

        public ActionResult Index()
        {
            String code  = Request.QueryString["code"];
            String state = Request.QueryString["state"];

            String authRequestUrl = String.Format(linkedInUrl, code, "http://euromoney-hackathon-team-c.azurewebsites.net/signinlinkedin", "75o0z7p1kzjgby", "12II1nRBNvbTb00l");

            HttpWebRequest authRequest = (HttpWebRequest)HttpWebRequest.Create(authRequestUrl);

            authRequest.Method = "POST";
            var     httpAuthResponse = (HttpWebResponse)authRequest.GetResponse();
            JObject authResultObject;

            using (var streamReader = new StreamReader(httpAuthResponse.GetResponseStream()))
            {
                var authResult = streamReader.ReadToEnd();
                authResultObject = JObject.Parse(authResult);
            }

            String accessToken = authResultObject.GetValue("access_token").ToString();


            String         profileRequestUrl = String.Format(linkedInProfileURL, profileFieldsList, accessToken);
            HttpWebRequest profileRequest    = (HttpWebRequest)HttpWebRequest.Create(profileRequestUrl);

            profileRequest.Method = "GET";
            profileRequest.Headers.Add("x-li-format: json");

            var     httpProfileResponse = (HttpWebResponse)profileRequest.GetResponse();
            JObject profileResultObject;

            using (var streamReader = new StreamReader(httpProfileResponse.GetResponseStream()))
            {
                var profileResult = streamReader.ReadToEnd();
                profileResultObject = JObject.Parse(profileResult);
            }
            //TODO: Extract company and interests from profileResultObject
            JArray positions    = (JArray)profileResultObject["positions"]["values"];
            JArray currPosArray = JArray.FromObject(positions.Where(x => (bool)JObject.FromObject(x).GetValue("isCurrent") == true));

            if (currPosArray.Count != 0)
            {
                queryWiki(currPosArray[0]["company"]["name"].ToString());
            }

            JArray skills = (JArray)profileResultObject["skills"]["values"];

            string[] interests = new string[] { };
            if (profileResultObject["interests"] != null)
            {
                interests = profileResultObject["interests"].ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }

            string[] companyName = currPosArray.Select(x => x["company"]["name"].ToString()).ToArray();
            string[] companyPosn = currPosArray.Select(x => x["title"].ToString()).ToArray();
            string[] skillsArr   = skills.Select(x => x["skill"]["name"].ToString()).ToArray();

            List <string> interestList = interests.ToList();

            interestList.AddRange(skillsArr);
            interests = interestList.ToArray();


            Person markLogicPerson = new Person(); //MarkLogicLayer.getPersonMLByEmail(profileResultObject.GetValue("emailAddress").ToString());

            markLogicPerson.FirstName          = profileResultObject["firstName"].ToString();
            markLogicPerson.LastName           = profileResultObject["lastName"].ToString();
            markLogicPerson.EmailAddress       = profileResultObject["emailAddress"].ToString();
            markLogicPerson.LinkedInUrl        = profileResultObject["publicProfileUrl"].ToString();
            markLogicPerson.CompanyName        = companyName;
            markLogicPerson.CompanyTitle       = companyPosn;
            markLogicPerson.Interests          = interests;
            markLogicPerson.LinkedInAccessCode = accessToken;

            Person existMLPerson = MarkLogicLayer.getPersonMLByEmail(markLogicPerson.EmailAddress);

            if (existMLPerson != null)
            {
                markLogicPerson.Id = existMLPerson.Id;
            }

            MarkLogicLayer.putPerson(markLogicPerson);
            return(View(JObject.FromObject(markLogicPerson)));
            //RedirectToAction();
        }