public PartialViewResult AddChildCommentEvent(int idOfParentId, string content) { if (SpamDetector.IsContentSpam(content)) { return(null); } var parentComment = context.CommentEvents.Find(idOfParentId); GamingEvent gameEvent = context.GamingEvents.Where(a => a.GamingEventId == parentComment.GamingEventId).First(); ApplicationUser user = null; string id = User.Identity.GetUserId(); if (id != string.Empty && id != null) { user = context.Users.Where(a => a.Id == id).First(); } CommentEvent commentEvent = new CommentEvent() { Body = content, DateOfInsert = DateTime.Now, GamingEventId = gameEvent.GamingEventId, UserId = User.Identity.GetUserId(), User = user, ParentCommentEventId = parentComment.CommentEventId, Parent = parentComment }; var sentimentalInt = new SentimentalInterpreter(); var isContentHappy = sentimentalInt.IsHappy(commentEvent.Body); if (isContentHappy) { commentEvent.IsHappy = true; } parentComment.Children.Add(commentEvent); context.CommentEvents.Add(commentEvent); context.SaveChanges(); CurrentCommentGameEventViewModel vm = new CurrentCommentGameEventViewModel { LoggedUser = user, Com = parentComment }; if (vm.Com.Children != null && vm.Com.Children.Count > 1) { vm.Com.Children = vm.Com.Children.OrderBy(a => a.DateOfInsert).ToList(); } return(PartialView("~/Views/GamingEvent/_ChildrenComments.cshtml", vm)); }
public PartialViewResult ListOfEventComment(GamingEvent element) { ApplicationUser user = null; string id = GetUserId(); if (id != string.Empty && id != null) { user = context.Users.Where(a => a.Id == id).First(); } CurrentGameEventUserViewModel vm = new CurrentGameEventUserViewModel { LoggedUser = user, GamingEvent = element }; return(PartialView("_ListOfComments", vm)); }
private void client_GetCompleted(object sender, FacebookApiEventArgs e) { dynamic items = dataGridFriendsEvents.ItemsSource ?? new List<GamingEvent>(); dynamic result = e.GetResultData(); Event eEvent = (Event)e.UserState; GamingEvent gEvent = new GamingEvent(); gEvent.Event = eEvent; if(result.description != null) gEvent.Description = result.description.ToString(); if(result.end_time != null) gEvent.EndTime = DateTime.Parse(result.end_time.ToString()); if (result.start_time != null) gEvent.StartTime = DateTime.Parse(result.start_time.ToString()); if (result.name != null) gEvent.Name = result.name.ToString(); if (result.location != null) gEvent.Location = result.location.ToString(); items.Add(gEvent); dataGridFriendsEvents.ItemsSource = items; }
private void ButtonEventsCreateSubmitNewEventClick(object sender, RoutedEventArgs e) { if ((listBoxEventsCreatePlatform.SelectedItem != null) && (listBoxEventsCreateGame.SelectedItem != null) && (comboBoxEventsCreateStartTime.SelectedItem != null) && (comboBoxEventsCreateEndTime.SelectedItem != null) && (textBoxEventsCreateEventName.Text != string.Empty) && (textBoxEventsCreateEventDetails.Text != string.Empty)) { GamingEvent gamingEvent = new GamingEvent(); if (eventsCalendar.SelectedDate != null) { DateTime selectedDate = (DateTime) eventsCalendar.SelectedDate; DateTime startTime = DateTime.Parse(comboBoxEventsCreateStartTime.SelectionBoxItem.ToString()); selectedDate = selectedDate.AddHours(startTime.Hour); startTime = selectedDate.AddMinutes(startTime.Minute); gamingEvent.StartTime = startTime; DateTime endTime = DateTime.Parse(comboBoxEventsCreateEndTime.SelectionBoxItem.ToString()); selectedDate = (DateTime) eventsCalendar.SelectedDate; selectedDate = selectedDate.AddHours(endTime.Hour); endTime = selectedDate.AddMinutes(endTime.Minute); gamingEvent.EndTime = endTime; } gamingEvent.Description = textBoxEventsCreateEventDetails.Text; Event gEvent = new Event(); gEvent.GameID = ((Game) listBoxEventsCreateGame.SelectedItem).ID; gEvent.Game = (Game) listBoxEventsCreateGame.SelectedItem; gamingEvent.Event = gEvent; gamingEvent.Location = string.Empty; gamingEvent.Name = textBoxEventsCreateEventName.Text; _gnsClient.CreateEventAsync(UserMe, gamingEvent, null); } }