public ActionResult MarkCommentHelpful(int commentId, string returnUrl) { try { int count = Db.HelpfulMarkGivenEvents .Where(c => c.EventLog.SenderId == CurrentUser.Id) .Where(c => c.LogCommentEventId == commentId) .Count(); if (count == 0) { LogCommentEvent comment = Db.LogCommentEvents.Where(c => c.Id == commentId).FirstOrDefault(); if (commentId != 0) { HelpfulMarkGivenEvent help = new HelpfulMarkGivenEvent() { LogCommentEventId = commentId }; OsbideWebService client = new OsbideWebService(); Authentication auth = new Authentication(); string key = auth.GetAuthenticationKey(); EventLog log = new EventLog(help, CurrentUser); client.SubmitLog(log, CurrentUser); } } } catch (Exception ex) { LogErrorMessage(ex); } Response.Redirect(returnUrl); return(View()); }
public void CanPostHelpfulMarkEvent() { // Arrange var log = new HelpfulMarkGivenEvent { SenderId = 1, SolutionName = "Dummy Solution", CourseId = 1, LogCommentEventId = 1 }; // Act var result = Posts.SaveEvent(log); // Assert using (var connection = new SqlConnection(StringConstants.ConnectionString)) { var savedlog = connection.Query <HelpfulMarkGivenEvent>( @"select b.EventLogId, a.EventTypeId, a.SenderId, b.SolutionName, a.CourseId, b.LogCommentEventId from EventLogs a inner join HelpfulMarkGivenEvents b on b.EventLogId=a.Id and a.Id=@id", new { @Id = result }).SingleOrDefault(); Assert.IsTrue(savedlog != null); Assert.IsTrue(savedlog.SenderId == log.SenderId); Assert.IsTrue(savedlog.EventType == log.EventType); Assert.IsTrue(savedlog.SolutionName == log.SolutionName); Assert.IsTrue(savedlog.CourseId == log.CourseId); Assert.IsTrue(savedlog.LogCommentEventId == log.LogCommentEventId); } }
/// <summary> /// Provides a details view for the provided Log IDs /// </summary> /// <param name="id">The ID(s) of the logs to retrieve. Accepts a comma delimited list. /// In the case of rendering multiple IDs, an aggregate view will be created /// </param> /// <returns></returns> public ActionResult Details(string id) { try { //make sure that we've gotten a valid ID if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index")); } //check to receive if we've gotten a single ID back int idAsInt = -1; if (Int32.TryParse(id, out idAsInt) == true) { //if we've received a log comment event or a helpful mark event, we have to reroute to the original event EventLog log = Db.EventLogs.Where(e => e.Id == idAsInt).FirstOrDefault(); //MarkReadProc.Update(idAsInt, CurrentUser.Id , true); if (log != null) { if (log.LogType == LogCommentEvent.Name) { LogCommentEvent commentEvent = Db.LogCommentEvents.Where(c => c.EventLogId == log.Id).FirstOrDefault(); return(RedirectToAction("Details", "Feed", new { id = commentEvent.SourceEventLogId })); } else if (log.LogType == HelpfulMarkGivenEvent.Name) { HelpfulMarkGivenEvent helpfulEvent = Db.HelpfulMarkGivenEvents.Where(e => e.EventLogId == log.Id).FirstOrDefault(); return(RedirectToAction("Details", "Feed", new { id = helpfulEvent.LogCommentEvent.SourceEventLogId })); } } } var query = new ActivityFeedQuery(); List <int> ids = ParseIdString(id); foreach (int logId in ids) { query.AddEventId(logId); } int testid = ids[0]; List <FeedItem> feedItems = query.Execute().ToList(); EventLog el = Db.EventLogs.Where(e => e.Id == testid).FirstOrDefault(); ExceptionEvent evt = Db.ExceptionEvents.Where(e => e.EventLogId == testid).FirstOrDefault(); FeedItem fi = new FeedItem() { Comments = new List <LogCommentEvent>(), //Creator = el.Sender, Event = evt, EventId = el.Id, HelpfulComments = 0, //Creator ItemDate = el.DateReceived, Log = el }; feedItems.Clear(); feedItems.Add(fi); List <AggregateFeedItem> aggregateItems = AggregateFeedItem.FromFeedItems(feedItems); //build the "you and 5 others got this error"-type messages FeedViewModel fvm = new FeedViewModel(); BuildEventRelations(fvm, feedItems); ViewBag.RecentUserErrors = fvm.RecentUserErrors; ViewBag.RecentClassErrors = fvm.RecentClassErrors; ViewBag.ErrorTypes = fvm.ErrorTypes; FeedDetailsViewModel vm = new FeedDetailsViewModel(); vm.Ids = id; vm.FeedItem = aggregateItems.FirstOrDefault(); if (Db.EventLogSubscriptions.Where(e => e.UserId == CurrentUser.Id).Where(e => e.LogId == ids.Min()).Count() > 0) { vm.IsSubscribed = true; } return(View(vm)); } catch (Exception ex) { LogErrorMessage(ex); return(RedirectToAction("FeedDown", "Error")); } }