public List <TopicaAccountInfo> Provide(FormDataCollection form) { var contactId = form.Get("contactId").ToInt32(); string linkTopicaSystem = ConfigurationManager.AppSettings["TopicaEnglishSystem"].ToString(); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; //string a = "http://tracnghiem.topicanative.edu.vn/webservice/rest/server.php?wstoken="+ token +"&wsfunction="+ function + "&moodlewsrestformat=json&contactid=" + contactId; // invoke the REST method byte[] data = client.DownloadData( linkTopicaSystem + "?wstoken=" + token + "&wsfunction=" + function + "&moodlewsrestformat=json&contactid=" + contactId); // put the downloaded data in a memory stream MemoryStream ms = new MemoryStream(); ms = new MemoryStream(data); // deserialize from json DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(TopicaAccountInfo)); TopicaAccountInfo result = ser.ReadObject(ms) as TopicaAccountInfo; var list = TopicaAccountRepository.UpdateTopicaAccount(contactId, result.username, result.password); ContactLevelInfoRepository.UpdateHasTopicaAccount(contactId, true); if (!list.IsNullOrEmpty()) { foreach (var item in list) { item.DateTimeString = item.DateTime.ToString("dd/MM/yyyy"); item.CreatedDateString = item.CreatedDate.ToString("dd/MM/yyyy"); item.StatusString = ObjectExtensions.GetEnumDescription((StatusTopicaType)item.StatusTopicaAccountId); } return(list); } return(null); }
public Result SendTopicaAccount(TopicaAccountInfo info) { return(null); }