public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { string str = string.Empty; try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken); LikeCounts++; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(str); }
public LikeControllerTests() { _likesController = new LikesController(_mocklikeService, _mapper, _mockcustomValidators); headerMap = new Dictionary <string, string>(); configuration = InitConfiguration(); }
public static void InstagramLikeUnLike(int LikeCount, int IsLike, string FeedId, string InstagramId, long groupId, Helper.AppSettings _appSettings, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed", _appSettings); Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(InstagramId, _redisCache, dbr); LikesController objlikes = new LikesController(); if (IsLike == 1) { LikeCount = LikeCount - 1; IsLike = 0; bool ret = objlikes.DeleteLike(FeedId, _Instagramaccounts.AccessToken); } else { LikeCount = LikeCount + 1; IsLike = 1; bool ret = objlikes.PostUserLike(FeedId, _Instagramaccounts.AccessToken); } FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", FeedId); var update = Builders <BsonDocument> .Update.Set("IsLike", IsLike).Set("LikeCount", LikeCount); instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter); }
public void LikesLikeShouldReturnOkResult() { var controller = new LikesController(this.likeService, this.userService); var result = controller.Like(1); Assert.IsNotNull(result); }
public void LikesDislikeShouldReturnOkResult() { var controller = new LikesController(this.likeService, this.userService); var result = controller.Dislike(1); Assert.IsNotNull(result); }
private string LikePost() { int userId = 0; int contentId = 0; if (Params.ContainsKey("userId") && SimulateIsNumeric.IsNumeric(Params["userId"])) { userId = int.Parse(Params["userId"].ToString()); } if (Params.ContainsKey("contentId") && SimulateIsNumeric.IsNumeric(Params["contentId"])) { contentId = int.Parse(Params["contentId"].ToString()); } var likeController = new LikesController(); likeController.Like(contentId, UserId); return(BuildOutput(userId + "|" + contentId, OutputCodes.Success, true)); }
public void Initialize() { _likeService = new Mock <ILikeService>(); _model = new Like(); _likeService.Setup(x => x.Like(_model)).Returns(() => new OperationStatus { IsSuccessful = true, ErrorMessage = "vwgnfwol" }); var context = new Mock <HttpContextBase>(); var identity = new GenericIdentity("*****@*****.**"); identity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", "1")); var principal = new GenericPrincipal(identity, new[] { "user" }); context.Setup(s => s.User).Returns(principal); _likeController = new LikesController(_userManager, _likeService.Object); // _likeController.ControllerContext = new ControllerContext(context.Object, new RouteData(), _likeController); }
public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { string str = string.Empty; GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken); LikeCounts++; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(str); }
public static void DeleteUser(string Email, string UserPermission) { if (UserPermission == "Broadcaster") { RadioBroadcastsController broadcastsController = new RadioBroadcastsController(); List <RadioBroadcast> myBroadcasts = broadcastsController.GetByEmail(Email); foreach (var broadcast in myBroadcasts) { broadcast.UserEmail = ""; broadcast.Username = ""; broadcastsController.Update(broadcast); } } LikesController likesController = new LikesController(); List <LikeBroadcast> myLike = new List <LikeBroadcast>(); myLike.AddRange(likesController.GetLikesByEmail(Email)); if (myLike.Count != 0) { foreach (var like in myLike) { likesController.Delete(like); } } CommentsController commentsController = new CommentsController(); List <BroadcastComment> myComments = new List <BroadcastComment>(); myComments.AddRange(commentsController.GetCommentsByEmail(Email)); if (myComments.Count != 0) { foreach (var comment in myComments) { commentsController.Delete(comment); } } }
public static void GetInstagramSelfFeeds(string instagramId, string accessToken, Helper.AppSettings _appSettings) { MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment", _appSettings); MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed", _appSettings); try { Users userInstagram = new Users(); Media _Media = new Media(); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); string feeds = _Media.UserResentFeeds(instagramId, accessToken); if (feeds != null) { JObject feed_data = JObject.Parse(feeds); foreach (var item in feed_data["data"]) { try { Domain.Socioboard.Models.Mongo.InstagramFeed objInstagramFeed = new Domain.Socioboard.Models.Mongo.InstagramFeed(); try { objInstagramFeed.FeedDate = Convert.ToDouble(item["created_time"].ToString()); } catch { } try { objInstagramFeed.FeedId = item["id"].ToString(); } catch { } try { objInstagramFeed.Type = item["type"].ToString(); if (objInstagramFeed.Type == "video") { objInstagramFeed.VideoUrl = item["videos"]["standard_resolution"]["url"].ToString(); } } catch { } try { objInstagramFeed.FeedImageUrl = item["images"]["standard_resolution"]["url"].ToString(); } catch { } try { objInstagramFeed.InstagramId = instagramId; } catch { } try { objInstagramFeed.LikeCount = Int32.Parse(item["likes"]["count"].ToString()); } catch { } try { objInstagramFeed.CommentCount = Int32.Parse(item["comments"]["count"].ToString()); } catch { } try { string str = item["user_has_liked"].ToString(); if (str.ToLower() == "false") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } } catch { } try { objInstagramFeed.AdminUser = item["user"]["username"].ToString(); } catch { } try { objInstagramFeed.Feed = item["caption"]["text"].ToString(); } catch { } try { objInstagramFeed.ImageUrl = item["user"]["profile_picture"].ToString(); } catch { } try { objInstagramFeed.FromId = item["user"]["id"].ToString(); } catch { } try { objInstagramFeed.FeedUrl = item["link"].ToString(); } catch { } var ret = instagramFeedRepo.Find <Domain.Socioboard.Models.Mongo.InstagramFeed>(t => t.FeedId.Equals(objInstagramFeed.FeedId) && t.InstagramId.Equals(objInstagramFeed.InstagramId)); var task = Task.Run(async() => { return(await ret); }); int count = task.Result.Count; if (count < 1) { instagramFeedRepo.Add(objInstagramFeed); } else { FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", objInstagramFeed.FeedId); var update = Builders <BsonDocument> .Update.Set("IsLike", objInstagramFeed.IsLike).Set("CommentCount", objInstagramFeed.CommentCount).Set("LikeCount", objInstagramFeed.LikeCount).Set("Type", objInstagramFeed.Type).Set("VideoUrl", objInstagramFeed.VideoUrl); instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter); } List <Domain.Socioboard.Models.Mongo.InstagramComment> lstInstagramComment = new List <Domain.Socioboard.Models.Mongo.InstagramComment>(); usercmts = objComment.GetComment(objInstagramFeed.FeedId, accessToken); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { Domain.Socioboard.Models.Mongo.InstagramComment objInstagramComment = new Domain.Socioboard.Models.Mongo.InstagramComment(); try { objInstagramComment.Comment = usercmts.data[cmt].text; } catch { } try { objInstagramComment.CommentDate = Convert.ToDouble(usercmts.data[cmt].created_time.ToString()); } catch { } try { objInstagramComment.CommentId = usercmts.data[cmt].id; } catch { } try { objInstagramComment.FeedId = objInstagramFeed.FeedId; } catch { } try { objInstagramComment.InstagramId = instagramId; } catch { } try { objInstagramComment.FromName = usercmts.data[cmt].from.username; } catch { } try { objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; } catch { } lstInstagramComment.Add(objInstagramComment); } catch (Exception ex) { } } instagarmCommentRepo.AddList(lstInstagramComment); } catch (Exception ex) { } } } } catch (Exception ex) { } }
private string ParseContent(DataRow dr, string tempate, int rowcount) { var sOutput = tempate; var replyId = dr.GetInt("ReplyId"); var topicId = dr.GetInt("TopicId"); var postId = replyId == 0 ? topicId : replyId; var contentId = dr.GetInt("ContentId"); var dateCreated = dr.GetDateTime("DateCreated"); var dateUpdated = dr.GetDateTime("DateUpdated"); var authorId = dr.GetInt("AuthorId"); var username = dr.GetString("Username"); var firstName = dr.GetString("FirstName"); var lastName = dr.GetString("LastName"); var displayName = dr.GetString("DisplayName"); var userTopicCount = dr.GetInt("TopicCount"); var userReplyCount = dr.GetInt("ReplyCount"); var postCount = userTopicCount + userReplyCount; var userCaption = dr.GetString("UserCaption"); var body = dr.GetString("Body"); var subject = dr.GetString("Subject"); var tags = dr.GetString("Tags"); var signature = dr.GetString("Signature"); var ipAddress = dr.GetString("IPAddress"); var memberSince = dr.GetDateTime("MemberSince"); var avatarDisabled = dr.GetBoolean("AvatarDisabled"); var userRoles = dr.GetString("UserRoles"); var isUserOnline = dr.GetBoolean("IsUserOnline"); var replyStatusId = dr.GetInt("StatusId"); var totalPoints = _enablePoints ? dr.GetInt("UserTotalPoints") : 0; var answerCount = dr.GetInt("AnswerCount"); var rewardPoints = dr.GetInt("RewardPoints"); var dateLastActivity = dr.GetDateTime("DateLastActivity"); var signatureDisabled = dr.GetBoolean("SignatureDisabled"); DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController(); DotNetNuke.Entities.Users.UserInfo author = uc.GetUser(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId, authorId); // Populate the user object with the post author info. var up = new User { UserId = authorId, UserName = username, FirstName = firstName.Replace("&#", "&#"), LastName = lastName.Replace("&#", "&#"), DisplayName = displayName.Replace("&#", "&#"), Profile = { UserCaption = userCaption, Signature = signature, DateCreated = memberSince, AvatarDisabled = avatarDisabled, Roles = userRoles, ReplyCount = userReplyCount, TopicCount = userTopicCount, AnswerCount = answerCount, RewardPoints = rewardPoints, DateLastActivity = dateLastActivity, PrefBlockAvatars = UserPrefHideAvatars, PrefBlockSignatures = UserPrefHideSigs, IsUserOnline = isUserOnline, SignatureDisabled = signatureDisabled } }; if (author != null) up.Email = author.Email; //Perform Profile Related replacements sOutput = TemplateUtils.ParseProfileTemplate(sOutput, up, PortalId, ModuleId, ImagePath, CurrentUserType, true, UserPrefHideAvatars, UserPrefHideSigs, ipAddress, UserId, TimeZoneOffset); // Replace Tags Control if (string.IsNullOrWhiteSpace(tags)) sOutput = TemplateUtils.ReplaceSubSection(sOutput, string.Empty, "[AF:CONTROL:TAGS]", "[/AF:CONTROL:TAGS]"); else { sOutput = sOutput.Replace("[AF:CONTROL:TAGS]", string.Empty); sOutput = sOutput.Replace("[/AF:CONTROL:TAGS]", string.Empty); var tagList = string.Empty; foreach (var tag in tags.Split(',')) { if (tagList != string.Empty) tagList += ", "; tagList += "<a href=\"" + Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.ViewType + "=search", ParamKeys.Tags + "=" + HttpUtility.UrlEncode(tag) }) + "\">" + tag + "</a>"; } sOutput = sOutput.Replace("[AF:LABEL:TAGS]", tagList); } // Use a string builder from here on out. var sbOutput = new StringBuilder(sOutput); if (_bModSplit) { sbOutput = sbOutput.Replace("[SPLITCHECKBOX]", "<div class=\"split-checkbox\" style=\"display:none;\"><input type=\"checkbox\" onChange=\"amaf_splitCheck(this);\" value=\"" + replyId + "\" /></div>"); } else { sbOutput = sbOutput.Replace("[SPLITCHECKBOX]", string.Empty); } // Row CSS Classes if (rowcount % 2 == 0) { sbOutput.Replace("[POSTINFOCSS]", "afpostinfo afpostinfo1"); sbOutput.Replace("[POSTTOPICCSS]", "afposttopic afpostreply1"); sbOutput.Replace("[POSTREPLYCSS]", "afpostreply afpostreply1"); } else { sbOutput.Replace("[POSTTOPICCSS]", "afposttopic afpostreply2"); sbOutput.Replace("[POSTINFOCSS]", "afpostinfo afpostinfo2"); sbOutput.Replace("[POSTREPLYCSS]", "afpostreply afpostreply2"); } // Description if (replyId == 0) { sbOutput.Replace("[POSTID]", topicId.ToString()); _topicDescription = Utilities.StripHTMLTag(body).Trim(); _topicDescription = _topicDescription.Replace(System.Environment.NewLine, string.Empty); if (_topicDescription.Length > 255) _topicDescription = _topicDescription.Substring(0, 255); } else { sbOutput.Replace("[POSTID]", replyId.ToString()); } sbOutput.Replace("[FORUMID]", ForumId.ToString()); sbOutput.Replace("[REPLYID]", replyId.ToString()); sbOutput.Replace("[TOPICID]", topicId.ToString()); sbOutput.Replace("[POSTDATE]", GetDate(dateCreated)); sbOutput.Replace("[DATECREATED]", GetDate(dateCreated)); // Parse Roles -- This should actually be taken care of in ParseProfileTemplate //if (sOutput.Contains("[ROLES:")) // sOutput = TemplateUtils.ParseRoles(sOutput, (up.UserId == -1) ? string.Empty : up.Profile.Roles); // Delete Action if (_bModDelete || ((_bDelete && authorId == UserId && !_bLocked) && ((replyId == 0 && _replyCount == 0) || replyId > 0))) { if (_useListActions) sbOutput.Replace("[ACTIONS:DELETE]", "<li onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i> [RESX:Delete]</li>"); else sbOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0);\" class=\"af-actions\" onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i> [RESX:Delete]</a>"); } else { sbOutput.Replace("[ACTIONS:DELETE]", string.Empty); } // Edit Action if (_bModEdit || (_bEdit && authorId == UserId && (_editInterval == 0 || SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, dateCreated, DateTime.Now) < _editInterval))) { var sAction = "re"; if (replyId == 0) sAction = "te"; //var editParams = new[] { ParamKeys.ViewType + "=post", "action=" + sAction, ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, "postid=" + postId }; var editParams = new List<string>() { ParamKeys.ViewType + "=post", "action=" + sAction, ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, "postid=" + postId }; if (SocialGroupId > 0) editParams.Add(ParamKeys.GroupIdName + "=" + SocialGroupId); if (_useListActions) sbOutput.Replace("[ACTIONS:EDIT]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", editParams) + "';\" title=\"[RESX:Edit]\"><i class=\"fa fa-pencil fa-fw fa-blue\"></i> [RESX:Edit]</li>"); else sbOutput.Replace("[ACTIONS:EDIT]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", editParams) + "\" title=\"[RESX:Edit]\"><i class=\"fa fa-pencil fa-fw fa-blue\"></i> [RESX:Edit]</a>"); } else { sbOutput.Replace("[ACTIONS:EDIT]", string.Empty); } // Reply and Quote Actions if (!_bLocked && CanReply) { var quoteParams = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.QuoteId + "=" + postId }; var replyParams = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId }; if (SocialGroupId > 0) { quoteParams.Add(ParamKeys.GroupIdName + "=" + SocialGroupId); replyParams.Add(ParamKeys.GroupIdName + "=" + SocialGroupId); } if (_useListActions) { sbOutput.Replace("[ACTIONS:QUOTE]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", quoteParams) + "';\" title=\"[RESX:Quote]\"><i class=\"fa fa-quote-left fa-fw fa-blue\"></i> [RESX:Quote]</li>"); sbOutput.Replace("[ACTIONS:REPLY]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", replyParams) + "';\" title=\"[RESX:Reply]\"><i class=\"fa fa-reply fa-fw fa-blue\"></i> [RESX:Reply]</li>"); } else { sbOutput.Replace("[ACTIONS:QUOTE]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", quoteParams) + "\" title=\"[RESX:Quote]\"><i class=\"fa fa-quote-left fa-fw fa-blue\"></i> [RESX:Quote]</a>"); sbOutput.Replace("[ACTIONS:REPLY]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", replyParams) + "\" title=\"[RESX:Reply]\"><i class=\"fa fa-reply fa-fw fa-blue\"></i> [RESX:Reply]</a>"); } } else { sbOutput.Replace("[ACTIONS:QUOTE]", string.Empty); sbOutput.Replace("[ACTIONS:REPLY]", string.Empty); } if (_bModMove) { sbOutput.Replace("[ACTIONS:MOVE]", "<li onclick=\"javascript:amaf_openMove([TOPICID])\"';\" title=\"[RESX:Move]\"><i class=\"fa fa-exchange fa-rotate-90 fa-blue\"></i> [RESX:Move]</li>"); } else { sbOutput = sbOutput.Replace("[ACTIONS:MOVE]", string.Empty); } sbOutput = sbOutput.Replace("[TOPICID]", TopicId.ToString()); // Status if (_statusId <= 0 || (_statusId == 3 && replyStatusId == 0)) { sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty); } else if (replyStatusId == 1) { // Answered if (_useListActions) sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-answered\" title=\"[RESX:Status:Answer]\"><em></em>[RESX:Status:Answer]</li>"); else sbOutput.Replace("[ACTIONS:ANSWER]", "<span class=\"af-actions af-answered\" title=\"[RESX:Status:Answer]\"><em></em>[RESX:Status:Answer]</span>"); } else { // Not Answered if ((UserId == _topicAuthorId && !_bLocked) || _bModEdit) { // Can mark answer if (_useListActions) sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-markanswer\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + ");\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</li>"); else sbOutput.Replace("[ACTIONS:ANSWER]", "<a class=\"af-actions af-markanswer\" href=\"#\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + "); return false;\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</a>"); } else { // Display Nothing sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty); } } // User Edit Date if (dateUpdated == dateCreated || dateUpdated == DateTime.MinValue || dateUpdated == Utilities.NullDate()) { sbOutput.Replace("[EDITDATE]", string.Empty); } else { sbOutput.Replace("[EDITDATE]", Utilities.GetDate(dateUpdated, ModuleId, TimeZoneOffset)); } // Mod Edit Date if (_bModEdit) { if (dateCreated == dateUpdated || dateUpdated == DateTime.MinValue || dateUpdated == Utilities.NullDate()) sbOutput.Replace("[MODEDITDATE]", string.Empty); else sbOutput.Replace("[MODEDITDATE]", Utilities.GetDate(dateUpdated, ModuleId, TimeZoneOffset)); } else { sbOutput.Replace("[MODEDITDATE]", string.Empty); } if (_allowLikes) { Image likeImage = new Image(); var likesController = new LikesController(); var likes = likesController.GetForPost(contentId); bool youLike = likes.Where(o => o.UserId == UserId) .Select(o => o.Checked) .FirstOrDefault(); string image = string.Empty; if (youLike) image = "fa-thumbs-o-up"; else image = "fa-thumbs-up"; likeImage.ImageUrl = image; if (CanReply) { sbOutput = sbOutput.Replace("[LIKES]", "<i class=\"fa " + image + "\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" > " + likes.Count.ToString() + "</i>"); sbOutput = sbOutput.Replace("[LIKESx2]", "<i class=\"fa " + image + " fa-2x\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" > " + likes.Count.ToString() + "</i>"); sbOutput = sbOutput.Replace("[LIKESx3]", "<i class=\"fa " + image + " fa-3x\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" > " + likes.Count.ToString() + "</i>"); } else { sbOutput = sbOutput.Replace("[LIKES]", "<i class=\"fa " + image + "\" /> " + likes.Count.ToString()); sbOutput = sbOutput.Replace("[LIKESx2]", "<i class=\"fa " + image + " fa-2x\" /> " + likes.Count.ToString()); sbOutput = sbOutput.Replace("[LIKESx3]", "<i class=\"fa " + image + " fa-3x\" /> " + likes.Count.ToString()); //sbOutput = sbOutput.Replace("[LIKES]", "<img src=\"" + image + "\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" /> " + likes.Count.ToString()); } } else { sbOutput = sbOutput.Replace("[LIKES]", string.Empty); sbOutput = sbOutput.Replace("[LIKESx2]", string.Empty); sbOutput = sbOutput.Replace("[LIKESx3]", string.Empty); } // Poll Results if (sOutput.Contains("[POLLRESULTS]")) { if (_topicType == 1) { var polls = new Polls(); sbOutput.Replace("[POLLRESULTS]", polls.PollResults(topicId, ImagePath)); } else { sbOutput.Replace("[POLLRESULTS]", string.Empty); } } // Mod Alert //var alertParams = new[] { ParamKeys.ViewType + "=modreport", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId }; var alertParams = new List<string> { ParamKeys.ViewType + "=modreport", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId }; if (SocialGroupId > 0) alertParams.Add(String.Format("{0}={1}", ParamKeys.GroupIdName, SocialGroupId)); if (Request.IsAuthenticated) { if (_useListActions) sbOutput.Replace("[ACTIONS:ALERT]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", alertParams) + "';\" title=\"[RESX:Alert]\"><i class=\"fa fa-bell-o fa-fw fa-blue\"></i> [RESX:Alert]</li>"); else sbOutput.Replace("[ACTIONS:ALERT]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", alertParams) + "\" title=\"[RESX:Alert]\"><i class=\"fa fa-bell-o fa-fw fa-blue\"></i> [RESX:Alert]</a>"); } else { sbOutput.Replace("[ACTIONS:ALERT]", string.Empty); } // Process Body if (string.IsNullOrEmpty(body)) body = " <br />"; var sBody = Utilities.ManageImagePath(body); sBody = sBody.Replace("[", "["); sBody = sBody.Replace("]", "]"); if (sBody.ToUpper().Contains("[CODE]")) { sBody = Regex.Replace(sBody, "([CODE])", "[CODE]", RegexOptions.IgnoreCase); sBody = Regex.Replace(sBody, "([\\/CODE])", "[/CODE]", RegexOptions.IgnoreCase); } //sBody = sBody.Replace("<CODE>", "<CODE>") if (Regex.IsMatch(sBody, "\\[CODE([^>]*)\\]", RegexOptions.IgnoreCase)) { var objCode = new CodeParser(); sBody = CodeParser.ParseCode(Utilities.HTMLDecode(sBody)); } sBody = Utilities.StripExecCode(sBody); if (MainSettings.AutoLinkEnabled) sBody = Utilities.AutoLinks(sBody, Request.Url.Host); if (sBody.Contains("<%@")) sBody = sBody.Replace("<%@ ", "<%@ "); if (body.ToLowerInvariant().Contains("runat")) sBody = Regex.Replace(sBody, "runat", "runat", RegexOptions.IgnoreCase); sbOutput.Replace("[BODY]", sBody); // Subject sbOutput.Replace("[SUBJECT]", subject); // Attachments sbOutput.Replace("[ATTACHMENTS]", GetAttachments(contentId, true, PortalId, ModuleId)); // Switch back from the string builder to a normal string before we perform the image/thumbnail replacements. sOutput = sbOutput.ToString(); // Legacy attachment functionality, uses "attachid" // [IMAGE:38] if (sOutput.Contains("[IMAGE:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/"; const string pattern = "([IMAGE:(.+?)])"; sOutput = Regex.Replace(sOutput, pattern, match => "<img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + match.Groups[2].Value + "\" border=\"0\" class=\"afimg\" />"); } // Legacy attachment functionality, uses "attachid" // [THUMBNAIL:38] if (sOutput.Contains("[THUMBNAIL:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/"; const string pattern = "([THUMBNAIL:(.+?)])"; sOutput = Regex.Replace(sOutput, pattern, match => { var thumbId = match.Groups[2].Value.Split(':')[0]; var parentId = match.Groups[2].Value.Split(':')[1]; return "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + parentId + "\" target=\"_blank\"><img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + thumbId + "\" border=\"0\" class=\"afimg\" /></a>"; }); } return sOutput; }
private string LikePost() { int userId = 0; int contentId = 0; if (Params.ContainsKey("userId") && SimulateIsNumeric.IsNumeric(Params["userId"])) { userId = int.Parse(Params["userId"].ToString()); } if (Params.ContainsKey("contentId") && SimulateIsNumeric.IsNumeric(Params["contentId"])) { contentId = int.Parse(Params["contentId"].ToString()); } var likeController = new LikesController(); likeController.Like(contentId, UserId); return BuildOutput(userId + "|" + contentId, OutputCodes.Success, true); }
public void getIntagramImages(object instaId) { Guid instaid = (Guid)instaId; InstagramAccountRepository objIns = new InstagramAccountRepository(); InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <InstagramMedia[]> userinf2 = new InstagramResponse <InstagramMedia[]>(); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); MediaController objMedia = new MediaController(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository(); InstagramFeed objFeed = new InstagramFeed(); InstagramComment objinsComment = new InstagramComment(); InstagramCommentRepository objInsRepo = new InstagramCommentRepository(); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = oAuthInstagram.GetInstance(configi); ArrayList aslt = objIns.getAllInstagramAccountsOfUser(instaid); string html = string.Empty; int i = 0; // string[] allhtmls = new string[aslt.Count]; string[] allhtmls = new string[0]; int countofimages = 0; foreach (InstagramAccount item in aslt) { try { GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); try { userinf2 = userInstagram.UserRecentMedia(item.InstagramId, string.Empty, string.Empty, "20", string.Empty, string.Empty, item.AccessToken); } catch { } } catch { } if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { usercmts = objComment.GetComment(userinf2.data[j].id, item.AccessToken); bool liked = false; try { liked = objLikes.LikeToggle(userinf2.data[j].id, item.InstagramId, item.AccessToken); } catch { } int n = usercmts.data.Count(); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { objinsComment.Comment = usercmts.data[cmt].text; objinsComment.CommentDate = usercmts.data[cmt].created_time.ToString(); objinsComment.CommentId = usercmts.data[cmt].id; objinsComment.EntryDate = DateTime.Now.ToString(); objinsComment.FeedId = userinf2.data[j].id; objinsComment.Id = Guid.NewGuid(); objinsComment.InstagramId = item.InstagramId; objinsComment.UserId = item.UserId; objinsComment.FromName = usercmts.data[cmt].from.full_name; objinsComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; if (!objInsRepo.checkInstagramCommentExists(usercmts.data[cmt].id, item.UserId)) { objInsRepo.addInstagramComment(objinsComment); } } objFeed.EntryDate = DateTime.Now; objFeed.FeedDate = userinf2.data[j].created_time.ToString(); objFeed.FeedId = userinf2.data[j].id; objFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); objFeed.InstagramId = item.InstagramId; objFeed.LikeCount = userinf2.data[j].likes.count; objFeed.UserId = item.UserId; if (!objInsFeedRepo.checkInstagramFeedExists(userinf2.data[j].id, item.UserId)) { objInsFeedRepo.addInstagramFeed(objFeed); } } catch { } i++; } } i++; // allhtmls[countofimages] = html; html = string.Empty; countofimages++; break; } string totalhtml = string.Empty; try { for (int k = 0; k < countofimages; k++) { totalhtml = totalhtml + allhtmls[k]; } } catch { } }
public string GetIntagramImages(Domain.Myfashion.Domain.InstagramAccount objInsAccount) { { InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <InstagramMedia[]> userinf2 = new InstagramResponse <InstagramMedia[]>(); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); MediaController objMedia = new MediaController(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); objInstagramComment = new Domain.Myfashion.Domain.InstagramComment(); objInstagramFeed = new Domain.Myfashion.Domain.InstagramFeed(); string html = string.Empty; int i = 0; string[] allhtmls = new string[0]; int countofimages = 0; GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); try { userinf2 = userInstagram.UserRecentMedia(objInsAccount.InstagramId, string.Empty, string.Empty, "20", string.Empty, string.Empty, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); bool liked = false; try { //liked = objLikes.LikeToggle(userinf2.data[j].id, objInsAccount.InstagramId, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } int n = usercmts.data.Count(); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { objInstagramComment.Comment = Uri.EscapeDataString(usercmts.data[cmt].text); objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString(); objInstagramComment.CommentId = usercmts.data[cmt].id; objInstagramComment.EntryDate = DateTime.Now; objInstagramComment.FeedId = userinf2.data[j].id; objInstagramComment.Id = Guid.NewGuid(); objInstagramComment.InstagramId = objInsAccount.InstagramId; objInstagramComment.UserId = objInsAccount.UserId; objInstagramComment.FromName = usercmts.data[cmt].from.full_name; objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInstagramCommentRepository.addInstagramComment(objInstagramComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } objInstagramFeed.EntryDate = DateTime.Now; try { objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.FeedId = userinf2.data[j].id; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.InstagramId = objInsAccount.InstagramId; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.LikeCount = userinf2.data[j].likes.count; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.UserId = objInsAccount.UserId; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.CommentCount = userinf2.data[j].comments.count; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { string str = userinf2.data[j].user_has_liked.ToString(); if (str == "False") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { objInstagramFeedRepository.addInstagramFeed(objInstagramFeed); } } catch (Exception ex) { logger.Error(ex.StackTrace); } i++; } } try { userinf2 = userInstagram.CurrentUserFeed(string.Empty, string.Empty, "20", objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); bool liked = false; try { // liked = objLikes.LikeToggle(userinf2.data[j].id, objInsAccount.InstagramId, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } int n = usercmts.data.Count(); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { objInstagramComment.Comment = Uri.EscapeDataString(usercmts.data[cmt].text); objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString(); objInstagramComment.CommentId = usercmts.data[cmt].id; objInstagramComment.EntryDate = DateTime.Now; objInstagramComment.FeedId = userinf2.data[j].id; objInstagramComment.Id = Guid.NewGuid(); objInstagramComment.InstagramId = objInsAccount.InstagramId; objInstagramComment.UserId = objInsAccount.UserId; objInstagramComment.FromName = usercmts.data[cmt].from.full_name; objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInstagramCommentRepository.addInstagramComment(objInstagramComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } objInstagramFeed.EntryDate = DateTime.Now; objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString(); objInstagramFeed.FeedId = userinf2.data[j].id; objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); objInstagramFeed.InstagramId = objInsAccount.InstagramId; objInstagramFeed.LikeCount = userinf2.data[j].likes.count; objInstagramFeed.CommentCount = userinf2.data[j].comments.count; string str = userinf2.data[j].user_has_liked.ToString(); if (str == "False") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username + "-" + userinf2.data[j].caption.from.full_name; objInstagramFeed.UserId = objInsAccount.UserId; if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { objInstagramFeedRepository.addInstagramFeed(objInstagramFeed); } } catch (Exception ex) { logger.Error(ex.StackTrace); } i++; } } i++; string totalhtml = string.Empty; try { for (int k = 0; k < countofimages; k++) { totalhtml = totalhtml + allhtmls[k]; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } // Session["AllHtmls"] = allhtmls; return(totalhtml); } }
public string getIntagramImages(InstagramAccount objInsAccount) { InstagramAccountRepository objIns = new InstagramAccountRepository(); InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <InstagramMedia[]> userinf2 = new InstagramResponse <InstagramMedia[]>(); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); MediaController objMedia = new MediaController(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository(); InstagramFeed objFeed = new InstagramFeed(); InstagramComment objinsComment = new InstagramComment(); InstagramCommentRepository objInsRepo = new InstagramCommentRepository(); // ArrayList aslt = objIns.getAllInstagramAccountsOfUser(instaid); string html = string.Empty; int i = 0; // string[] allhtmls = new string[aslt.Count]; string[] allhtmls = new string[0]; int countofimages = 0; GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); try { userinf2 = userInstagram.UserRecentMedia(objInsAccount.InstagramId, string.Empty, string.Empty, "20", string.Empty, string.Empty, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); bool liked = false; try { liked = objLikes.LikeToggle(userinf2.data[j].id, objInsAccount.InstagramId, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } int n = usercmts.data.Count(); for (int cmt = usercmts.data.Count() - 1; cmt > usercmts.data.Count() - 3; cmt--) { try { objinsComment.Comment = usercmts.data[cmt].text; objinsComment.CommentDate = usercmts.data[cmt].created_time.ToString(); objinsComment.CommentId = usercmts.data[cmt].id; objinsComment.EntryDate = DateTime.Now.ToString(); objinsComment.FeedId = userinf2.data[j].id; objinsComment.Id = Guid.NewGuid(); objinsComment.InstagramId = objInsAccount.InstagramId; objinsComment.UserId = objInsAccount.UserId; objinsComment.FromName = usercmts.data[cmt].from.full_name; objinsComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; if (!objInsRepo.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInsRepo.addInstagramComment(objinsComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } objFeed.EntryDate = DateTime.Now; objFeed.FeedDate = userinf2.data[j].created_time.ToString(); objFeed.FeedId = userinf2.data[j].id; objFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); objFeed.InstagramId = objInsAccount.InstagramId; objFeed.LikeCount = userinf2.data[j].likes.count; objFeed.UserId = objInsAccount.UserId; if (!objInsFeedRepo.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { objInsFeedRepo.addInstagramFeed(objFeed); } } catch (Exception ex) { logger.Error(ex.StackTrace); } i++; } } i++; string totalhtml = string.Empty; try { for (int k = 0; k < countofimages; k++) { totalhtml = totalhtml + allhtmls[k]; } } catch (Exception ex) { logger.Error(ex.StackTrace); } Session["AllHtmls"] = allhtmls; return(totalhtml); }
public void GetInstagramFeeds(Domain.Myfashion.Domain.InstagramAccount objInsAccount) { int I = 0; try { GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); InstagramResponse <InstagramMedia[]> userinf2 = userInstagram.CurrentUserFeed("", "", "20", objInsAccount.AccessToken); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); objInstagramComment = new Domain.Myfashion.Domain.InstagramComment(); objInstagramFeed = new Domain.Myfashion.Domain.InstagramFeed(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { objInstagramFeed.EntryDate = DateTime.Now; try { objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString(); } catch { } try { objInstagramFeed.FeedId = userinf2.data[j].id; } catch { } try { objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); } catch { } try { objInstagramFeed.InstagramId = objInsAccount.InstagramId; } catch { } try { objInstagramFeed.LikeCount = userinf2.data[j].likes.count; } catch { } try { objInstagramFeed.CommentCount = userinf2.data[j].comments.count; } catch { } try { string str = userinf2.data[j].user_has_liked.ToString(); if (str == "False") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } } catch { } try { objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username; } catch { } try { objInstagramFeed.Feed = userinf2.data[j].caption.text; } catch { } try { objInstagramFeed.ImageUrl = userinf2.data[j].caption.from.profile_picture; } catch { } try { objInstagramFeed.FromId = userinf2.data[j].caption.from.id; } catch { } try { objInstagramFeed.FeedUrl = userinf2.data[j].link; } catch { } try { objInstagramFeed.UserId = objInsAccount.UserId; } catch { } if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { I++; objInstagramFeedRepository.addInstagramFeed(objInstagramFeed); logger.Error("GetInstagramFeedsCount>>>" + I); } usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { try { objInstagramComment.Comment = usercmts.data[cmt].text; } catch { } try { objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString(); } catch { } try { objInstagramComment.CommentId = usercmts.data[cmt].id; } catch { } try { objInstagramComment.EntryDate = DateTime.Now; } catch { } try { objInstagramComment.FeedId = userinf2.data[j].id; } catch { } try { objInstagramComment.Id = Guid.NewGuid(); } catch { } try { objInstagramComment.InstagramId = objInsAccount.InstagramId; } catch { } try { objInstagramComment.UserId = objInsAccount.UserId; } catch { } try { objInstagramComment.FromName = usercmts.data[cmt].from.username; } catch { } try { objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; } catch { } if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInstagramCommentRepository.addInstagramComment(objInstagramComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } } catch (Exception ex) { logger.Error(ex.Message); } } } } catch (Exception ex) { logger.Error(ex.Message); } }
public void CtorShouldWork() { var dog = new CreateDogViewModel { Name = "Pesho", BirthDate = DateTime.UtcNow, Province = Province.Burgas, IsDisinfected = true, IsVaccinated = false, OwnerNotes = "BlaBla", Breed = DogBreed.JackRussellTerrier }; this.createDog = dog; var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("ResqueDb") .Options; var db = new ApplicationDbContext(options); this.context = db; var store = new Mock <IUserStore <User> >(); var userManager = new Mock <UserManager <User> >(store.Object, null, null, null, null, null, null, null, null); var claims = new List <Claim>() { new Claim(ClaimTypes.Email, "*****@*****.**") }; var identity = new ClaimsIdentity(claims, "TestAuthType"); var claimsPrincipal = new ClaimsPrincipal(identity); var fakeUser = new User { Email = "*****@*****.**", FirstName = "Pesho", LastName = "Gosho", Province = Province.Blagoevgrad, BirthDate = DateTime.UtcNow }; this.context.Users.Add(fakeUser); this.context.SaveChanges(); userManager.Setup(u => u.GetUserAsync(claimsPrincipal)).ReturnsAsync(this.context.Users.FirstOrDefault(u => u.Email == "*****@*****.**")); userManager.Setup(u => u.GetUserId(claimsPrincipal)).Returns(this.context.Users.FirstOrDefault(u => u.Email == "*****@*****.**").Id); this.userManager = userManager.Object; var likesController = new LikesController(this.context, this.userManager); likesController.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = claimsPrincipal } }; this.likesController = likesController; }