public async Task <InpowerResult> PostGroupMessageService(GroupMessageRequestViewModel groupSend) { InpowerResult resp = null; try { resp = await _helper.Post <GroupMessageRequestViewModel>(groupSend, GlobalConstant.GroupChatUrls.PostMessageGroupUrl.ToString()); return(resp); } catch (Exception ex) { CrashReportService crashReport = new CrashReportService(); CrashReportModel CR = new CrashReportModel(); CR.Filename = "Registration"; CR.Eventname = "AccountService"; // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID; CR.ErrorMsg = ex.Message + ex.StackTrace; await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl); return(resp); } }
public async void ButtonSendChatMessage(string sMessageText) { try { if (!string.IsNullOrEmpty(sMessageText)) { var GroupTempSaveMessage = new GroupMessageResponseViewModel { GroupId = contactViewModel.GroupId, Message = sMessageText.Trim(' ', '\n'), Attachments = lstAttachments ?? new List <AttachmentViewModel>(), SenderId = CommonHelper.GetUserId(), MessageTime = DateTime.Now.ToUniversalTime() }; var message = GroupRepository.SaveGroupMessage(GroupTempSaveMessage, "Private"); var GroupSend = new GroupMessageRequestViewModel { GroupId = contactViewModel.GroupId, Message = sMessageText.Trim(' ', '\n'), Attachments = lstAttachments ?? new List <AttachmentViewModel>(), MobileDatabaseId = message.id }; lstAttachments = new List <AttachmentViewModel>(); try { var result = await new GroupChatService().PostGroupMessageService(GroupSend); if (result.Status == 1) { var GroupMessagelist = JsonConvert.DeserializeObject <GroupMessageResponseViewModel>(result.Response.ToString()); Console.WriteLine("posted successfully in grp"); var chatConversationResponce = ChatConversationRepository.GetConversationbyGroupId(GroupMessagelist.GroupId); if (chatConversationResponce.success) { ChatConversationRepository.UpdateChatLastMessage(chatConversationResponce.chatConversation.id, GroupMessagelist.Message, GroupMessagelist.SenderProfileName); } var savedItem = GroupRepository.UpdateGroupMessage(GroupMessagelist); await _objChatSignalRService.SendGroup(GroupMessagelist, GroupMessagelist.GroupId); LoadLocalLatestMessages(); } else { Console.WriteLine("post failed in grp"); } } catch (Exception ex) { Crashes.TrackError(ex); } } } catch (Exception ex) { Crashes.TrackError(ex); } }