public string GetTumblrAccountDetailsById(string UserId, string ProfileId) { try { Domain.Myfashion.Domain.TumblrAccount objTumblrAccount=new Domain.Myfashion.Domain.TumblrAccount (); objTumblrAccount.UserId = Guid.Parse(UserId); objTumblrAccount.tblrUserName = ProfileId; if(objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(ProfileId, Guid.Parse(UserId)); } else { objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(ProfileId); } return new JavaScriptSerializer().Serialize(objTumblrAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return "Something Went Wrong"; } }
public string GetTumblrAccountDetailsById(string UserId, string ProfileId) { try { Domain.Myfashion.Domain.TumblrAccount objTumblrAccount = new Domain.Myfashion.Domain.TumblrAccount(); objTumblrAccount.UserId = Guid.Parse(UserId); objTumblrAccount.tblrUserName = ProfileId; if (objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(ProfileId, Guid.Parse(UserId)); } else { objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(ProfileId); } return(new JavaScriptSerializer().Serialize(objTumblrAccount)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return("Something Went Wrong"); } }
public string TumblrSearch(string keyword) { string ret = string.Empty; string outputface = string.Empty; try { string key = ConfigurationManager.AppSettings["TumblrClientKey"]; TumblrAccountRepository tumaccrepo = new TumblrAccountRepository(); Domain.Myfashion.Domain.TumblrAccount TumComAcc = tumaccrepo.getTumblrAccountDetailsById(keyword); if (TumComAcc != null && !string.IsNullOrEmpty(TumComAcc.tblrUserName)) { string TumblrSearchUrl = "http://api.tumblr.com/v2/blog/" + TumComAcc.tblrUserName + ".tumblr.com/posts/text?api_key=" + key + "&limit=10"; var TumblrBlogpagerequest = (HttpWebRequest)WebRequest.Create(TumblrSearchUrl); TumblrBlogpagerequest.Method = "GET"; try { using (var response = TumblrBlogpagerequest.GetResponse()) { using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252))) { outputface = stream.ReadToEnd(); } } } catch (Exception ex) { } } else { string TumblrSearchUrl = "http://api.tumblr.com/v2/blog/" + keyword.Replace(" ", string.Empty) + ".tumblr.com/posts/text?api_key=" + key + "&limit=10"; var TumblrBlogpagerequest = (HttpWebRequest)WebRequest.Create(TumblrSearchUrl); TumblrBlogpagerequest.Method = "GET"; try { using (var response = TumblrBlogpagerequest.GetResponse()) { using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252))) { outputface = stream.ReadToEnd(); } } JObject outputJson = JObject.Parse(outputface); Domain.Myfashion.Domain.TumblrAccount newtumbobj = new Domain.Myfashion.Domain.TumblrAccount(); newtumbobj.tblrUserName = outputJson["response"]["blog"]["name"].ToString(); TumblrAccountRepository.Add(newtumbobj); } catch (Exception ex) { } } } catch (Exception ex) { throw; } return outputface; }