public async Task <ConversationVM> GetLastConvo([FromQuery] String coach) { if (coach == null) { return(new ConversationVM()); } var user = await _userManager.GetUserAsync(User); var conversation = _context.Conversations .Include(i => i.QuestionsAsked) .Include(i => i.ResponseList) .Include(i => i.Coach) .OrderByDescending(e => e.DateTime) .FirstOrDefault(m => m.UserData.Email == user.Email && m.inProgress == false && m.Coach.Name.ToLower() == coach.ToLower()); if (conversation == null) { return(new ConversationVM()); } conversation.QuestionsAsked = conversation.QuestionsAsked.OrderBy(i => i.Index).ToList(); conversation.ResponseList = conversation.ResponseList.OrderBy(i => i.Index).ToList(); string longStr = "Journal entry at " + DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToShortTimeString() + " by " + user.FirstName; //build item list List <GcItem> itemList = new List <GcItem>(); int q = 0; foreach (var item in conversation.QuestionsAsked) { itemList.Add(new GcItem { Content = item.QuestionText, Author = "Coach " + conversation.Coach.Name, compstyle = "coach", Type = "" }); if (q < conversation.ResponseList.Count) { var response = conversation.ResponseList[q]; itemList.Add(new GcItem { Content = response.IsTextResponse ? response.TextResponse : response.NumResponse.ToString(), Author = user.FirstName, compstyle = "", Type = "" }); } q++; } var vm = new ConversationVM { DateStr = conversation.DateTime.ToShortDateString(), ItemList = itemList, LongDateStr = longStr }; return(vm); }
public void GetMessage(string text, string from, int fromId, string fromImage, string to, int toId) { Conversation[] conversations = this.documentManagerVM.CurrentUserVM.Model.Root.Messages.Cast <Conversation>().ToArray(); foreach (Conversation c in conversations) { if (c.Name == from && c.IdUserName == fromId) { Conversation = c; } } if (Conversation != null) { Message message = ViewModelUtility.modelFactory("Delivered", Conversation, text); if (message != null) { Conversation.Messages.Add(message); } ConversationVM selected = ListOfConversations.SelectedItem as ConversationVM; if (Conversation.Name != selected.Model.Parent.Name) { Conversation.Seen = 1; ListOfConversations.ItemsSource = null; ListOfConversations.ItemsSource = this.documentManagerVM.CurrentUserVM.RootVM.Messages; soundPlayer.Play(); } else { Conversation.Seen = 0; ListOfConversations.ItemsSource = null; ListOfConversations.ItemsSource = this.documentManagerVM.CurrentUserVM.RootVM.Messages; soundPlayer.Play(); } } else { Conversation con = new Conversation(this.documentManagerVM.CurrentUserVM.Model.Root); con.Name = from; con.Image = fromImage; con.IdUserName = fromId; con.Messages.Add(new Delivered(con) { CreationDate = DateTime.UtcNow, Text = text }); con.Seen = 1; this.documentManagerVM.CurrentUserVM.Model.Root.Messages.Add(con); soundPlayer.Play(); } }
public void OnSubmit() { if (target == null) { return; } int valueInt = 0; string valueStr = ""; switch (currentInputMode) { case InputCharacterQty: case InputInventoryQty: valueInt = ParseInteger(); break; case InputConversationWords: case InputMantraWords: case InputAnvil: valueStr = ParseString(); break; } UWHUD.instance.InputControl.text = ""; switch (currentInputMode) { case InputCharacterQty: target.gameObject.GetComponent <UWCharacter>().OnSubmitPickup(valueInt); break; case InputInventoryQty: target.gameObject.GetComponent <InventorySlot>().OnSubmitPickup(valueInt); break; case InputConversationWords: //target.gameObject.GetComponent<Conversation>().OnSubmitPickup(valueStr); ConversationVM.OnSubmitPickup(valueStr); break; case InputMantraWords: target.gameObject.GetComponent <Shrine>().OnSubmitPickup(valueStr); break; case InputAnvil: target.gameObject.GetComponent <Equipment>().OnSubmitPickup(valueStr); currentInputMode = InputNone; break; } UWHUD.instance.InputControl.text = ""; }
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.documentManagerVM.CurrentUserVM.CurrentConversationVM = ListOfConversations.SelectedItem as ConversationVM; grdMessageControl.Visibility = Visibility.Visible; if (ListOfConversations.SelectedItem == null) { return; } else { ConversationSeen = this.documentManagerVM.CurrentUserVM.CurrentConversationVM.Model as Conversation; ConversationVM ConversationSennUpdated = this.documentManagerVM.CurrentUserVM.CurrentConversationVM; if (ConversationSeen.Seen != 0) { ConversationSeen.Seen = 0; } } }
public virtual JsonResult AddComment(long articleId, string textComment, long? conversationId) { ProviderCurrentMember currentMember = ProviderCurrentMember.Instance; AjaxReturnMsgVM viewModel = new AjaxReturnMsgVM { StatusCode = AjaxReturnMsgVM.Status.success, StatusMessage = String.Empty }; ContentCheck result = null; if (!currentMember.IsSuperAdmin) { string email = string.Empty; string domain = string.Empty; if (currentMember.HasValidAltId(ProviderAlternateMemberId.AlternateType.Email)) { email = currentMember.Emails[0].Email.Address; } if (currentMember.HasValidAltId(ProviderAlternateMemberId.AlternateType.Domain)) { domain = currentMember.Domains[0].Domain.AbsoluteUri; } // The mollom client crashes if passed in special html chars ( ) so strip those before sending it over string cleanedTextComment = HtmlParser.StripSpecialChars(textComment); MollomClient client = new MollomClient(InsideWordWebSettings.MollomPrivateKey, InsideWordWebSettings.MollomPublicKey); result = client.CheckContent(string.Empty, cleanedTextComment, currentMember.DisplayAdministrativeName, email, domain, HttpContext.Request.UserHostAddress); } if (!currentMember.IsLoggedOn) { viewModel.StatusCode = AjaxReturnMsgVM.Status.failure; viewModel.StatusMessage = "You must be logged in to Comment."; } else if (!ProviderArticle.Exists(articleId)) { viewModel.StatusCode = AjaxReturnMsgVM.Status.failure; viewModel.StatusMessage = "The article you commented on no longer exists."; } else if(string.IsNullOrEmpty(textComment) || textComment.Length < 2) { viewModel.StatusCode = AjaxReturnMsgVM.Status.failure; viewModel.StatusMessage = "A comment needs more than 1 character."; } else if(textComment.Length > ProviderComment.TextSize) { viewModel.StatusCode = AjaxReturnMsgVM.Status.failure; viewModel.StatusMessage = "A comment can't be more than "+ProviderComment.TextSize+ " characters."; } else if (result != null && result.Classification == ContentClassification.Spam) { viewModel.StatusCode = AjaxReturnMsgVM.Status.failure; viewModel.StatusMessage = "Your comment has been blocked as spam."; } else if (result != null && result.Quality < InsideWordWebSettings.MollomCommentQuality) { viewModel.StatusCode = AjaxReturnMsgVM.Status.failure; viewModel.StatusMessage = "The quality of your comment is too low. Try improving things such as spelling and grammar."; } else { ProviderArticle anArticle = new ProviderArticle(articleId); ProviderConversation conversation; if (conversationId.HasValue) { conversation = new ProviderConversation(conversationId.Value); } else { conversation = new ProviderConversation(); } ProviderComment comment = new ProviderComment(); CommentBL.AddComment(textComment, currentMember, anArticle, ref conversation, ref comment); ProviderMember author = anArticle.Author; long? articleAuthorId = null; if (author != null) { articleAuthorId = author.Id; } bool isReply = conversation.Comments.Count > 1; if (isReply) { CommentVM commentVM = new CommentVM(comment, currentMember, articleAuthorId); commentVM.IsReply = isReply; viewModel.Content = ControllerExtension.RenderPartialViewToString(this, MVC.Child.Views.Comment, (object)commentVM); } else { ConversationVM conversationVM = new ConversationVM(conversation, ProviderCurrentMember.Instance, articleAuthorId); viewModel.Content = ControllerExtension.RenderPartialViewToString(this, MVC.Child.Views.Conversation, (object)conversationVM); } if (author != null && author.Id != currentMember.Id && author.HasValidAltId(ProviderAlternateMemberId.AlternateType.Email)) { // do some calculations to determine if we should send the e-mail int commentCount = anArticle.CountComments; int n = (int)Math.Log((double)commentCount, 2); if (n < 0) { n = 0; } if (commentCount % (1 << n) == 0) { EmailManager.Instance.SendCommentNotificationEmail(author.Emails[0].Email, anArticle, currentMember); } } } return Json(viewModel); }
public void PlayerSlotLeftClick() { if (TradeSlot.Locked) { return; } if (UWCharacter.Instance.playerInventory.ObjectInHand != "") { //put the object in hand in this slot. if (objectInSlot == "") { //Empty slot GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand(); if (objToMove != null) { if (objToMove.transform.parent != GameWorldController.instance.DynamicObjectMarker()) { //Object needs to be moved to world //objToMove.transform.parent= GameWorldController.instance.DynamicObjectMarker(); GameWorldController.MoveToWorld(objToMove); ConversationVM.BuildObjectList(); } objectInSlot = UWCharacter.Instance.playerInventory.ObjectInHand; UWCharacter.Instance.playerInventory.ObjectInHand = ""; SlotImage.texture = UWHUD.instance.CursorIcon; UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault; Selected = true; } } else { //Swap the objects GameObject objInSlot = GetGameObjectInteraction().gameObject; GameObject objInHand = UWCharacter.Instance.playerInventory.GetGameObjectInHand(); if (objInSlot != null) { objInSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(objInSlot); //This will call rebuild list } if (objInHand != null) { if (objInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker()) { //Object needs to be moved to world //objInHand.transform.parent= GameWorldController.instance.DynamicObjectMarker(); GameWorldController.MoveToWorld(objInHand); } } objectInSlot = objInHand.name; SlotImage.texture = objInHand.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture; UWHUD.instance.CursorIcon = objInSlot.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture; UWCharacter.Instance.playerInventory.ObjectInHand = objInSlot.name; ConversationVM.BuildObjectList(); Selected = true; } } else { if (objectInSlot != "") { //Pickup the object in the slot UWCharacter.Instance.playerInventory.SetObjectInHand(objectInSlot); UWHUD.instance.CursorIcon = UWCharacter.Instance.playerInventory.GetGameObject(objectInSlot).GetComponent <ObjectInteraction>().GetInventoryDisplay().texture; objectInSlot = ""; SlotImage.texture = Blank; Selected = false; GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand(); if (objToMove != null) { objToMove.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(objToMove); //This will call rebuild list objToMove.GetComponent <object_base>().PickupEvent(); } } } if (objectInSlot == "") { Quantity.text = ""; } else { int qty = GetGameObjectInteraction().GetQty(); if (qty <= 1) { Quantity.text = ""; } else { Quantity.text = qty.ToString(); } } }
public void PlayerSlotLeftClick() { if (TradeSlot.Locked) { return; } ObjectInteraction objIntAtSlot = GetGameObjectInteraction(); if (CurrentObjectInHand != null) { //put the object in hand in this slot. if (objectInSlot == null) { //Empty slot if (CurrentObjectInHand != null) { if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker()) { //Object needs to be moved to world GameWorldController.MoveToWorld(CurrentObjectInHand); ConversationVM.BuildObjectList(); } objectInSlot = CurrentObjectInHand; SlotImage.texture = UWHUD.instance.CursorIcon; CurrentObjectInHand = null; Selected = true; } } else { //Swap the objects if (objIntAtSlot != null) { objIntAtSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(objIntAtSlot); //This will call rebuild list } if (CurrentObjectInHand != null) { if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker()) { //Object needs to be moved to world GameWorldController.MoveToWorld(CurrentObjectInHand); } } objectInSlot = CurrentObjectInHand; SlotImage.texture = CurrentObjectInHand.GetInventoryDisplay().texture; CurrentObjectInHand = objIntAtSlot; ConversationVM.BuildObjectList(); Selected = true; } } else { if (objectInSlot != null) { //Pickup the object in the slot CurrentObjectInHand = objIntAtSlot; objectInSlot = null; SlotImage.texture = Blank; Selected = false; if (CurrentObjectInHand != null) { CurrentObjectInHand.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(CurrentObjectInHand); //This will call rebuild list CurrentObjectInHand.GetComponent <object_base>().PickupEvent(); } } } if (objectInSlot == null) { Quantity.text = ""; } else { int qty = GetGameObjectInteraction().GetQty(); if (qty <= 1) { Quantity.text = ""; } else { Quantity.text = qty.ToString(); } } }
public virtual ActionResult Conversation(ConversationVM viewModel) { return View(viewModel); }