private async Task <List <AllChats> > chatData(List <VendorChat> data) { var result = new List <AllChats>(); foreach (var d in data) { if (!result.Any(x => x.VendorId == d.VendorId && x.CustomerId == d.CustomerId)) { var r = new AllChats(); var msg = await db.VendorChatMsg.Where(x => x.VendorChatId == d.Id).LastOrDefaultAsync(); var detail = await db.ProductVariantDetails.Where(x => x.Id == d.ProductVariantDetailId).Include(x => x.Product.ProductImages).FirstOrDefaultAsync(); r.CustomerId = d.CustomerId; r.Date = msg.DateTime; r.LastMsg = msg.CustomerMsg == null ? msg.VendorMsg : msg.CustomerMsg; r.ProductVariantDetailId = d.ProductVariantDetailId; r.ProductId = detail.ProductId; r.VendorId = detail.Product.VendorId; r.VendorName = db.Users.Where(x => x.Id == r.VendorId).FirstOrDefault().DisplayName; r.ProductImage = detail.Product.ProductImages.Where(x => x.IsActive == true && x.IsDefault == true).FirstOrDefault() == null?detail.Product.ProductImages.Where(x => x.IsActive == true).FirstOrDefault().ImagePath150x150 : detail.Product.ProductImages.Where(x => x.IsActive == true && x.IsDefault == true).FirstOrDefault().ImagePath150x150; result.Add(r); } } return(result); }
private bool saveNotification(AllChats check) { var noti = new Notification(); noti.CreatedDate = System.DateTime.Now; noti.DeletedDate = null; noti.ReadDate = null; noti.IsRead = false; noti.IsDeleted = false; noti.IsActive = true; noti.NotificationTypeId = Convert.ToInt32(Helper.NotificationType.chat); noti.Title = "Got message"; noti.SpanishTitle = "tengo mensaje"; noti.Description = ("you got a new message from " + check.CustomerName).ToString(); noti.SpanishDescription = ("recibiste un nuevo mensaje de " + check.CustomerName).ToString(); var TargetURL = db.NotificationTypes.Where(b => b.Id == Convert.ToInt32(Helper.NotificationType.chat) && b.IsActive == true) .FirstOrDefault()?.BaseURL + "?Id=" + check.ProductId + "&variantId=" + check.ProductVariantDetailId + "&CustomId=" + check.CustomerId; noti.TargetURL = TargetURL; noti.UserId = check.VendorId; //----saving notification of purcahse order var users = new List <int>(); users.Add(check.VendorId); var status = NotificationHelper.saveNotification(noti, db, users); return(status); }
private void AuthModeStart(LoginData p_login_data) { AutheMode_Panel.Visible = true; own_user_name = p_login_data.Get_user_name; friends_and_status = p_login_data.Get_friends_list_and_status; public_chat_ids = p_login_data.Get_public_chat_ids; all_agreement_invitations = p_login_data.Get_agreement_invitations; received_offline_messages = p_login_data.Get_offline_messages; OwnUserName_Label.Text = "LoggedAs: " + own_user_name; select_public_chat_is_open = false; menuStrip1.Visible = true; all_show_agreement_invitations_forms = new List <AgreementInvitation_Form>(); all_show_formal_message_forms = new List <ShowFormalMessage_Form>(); ShowFriends(); foreach (AgreementInvitationInfo t_agreement_invitation_info in all_agreement_invitations) { AgreementInvitation_Form t_new_agreement_invitation_show_form = new AgreementInvitation_Form(t_agreement_invitation_info , new RemoveShowAgreementInvitationForm(RemoveShowAgreementInvitationForm), new CreateGetAgreementAnswerDialog(Mo_CreateGetAgreementAnswerDialog)); if (!all_show_agreement_invitations_forms.Contains(t_new_agreement_invitation_show_form)) { all_show_agreement_invitations_forms.Add(t_new_agreement_invitation_show_form); t_new_agreement_invitation_show_form.StartForm(); } else { t_new_agreement_invitation_show_form.DontStartForm(); } } if (received_offline_messages.Count > 0) { ShowFormalMessage_Form show_offline_messages_form = new ShowFormalMessage_Form(received_offline_messages, new OfflienMesssageRead(Mo_ServerOfflineMessagesReadInform) , new RemoveShowOfflineMessagesForm(RemoveShowOfflineMessagesFormFromList)); if (!all_show_formal_message_forms.Contains(show_offline_messages_form)) { all_show_formal_message_forms.Add(show_offline_messages_form); show_offline_messages_form.StartForm(); } else { show_offline_messages_form.DontStartForm(); } } Cl_ClientDelegatesForDialogs all_dialogs_delegates = new Cl_ClientDelegatesForDialogs(new SendDialogMessage(Mo_SendDialogMessage), new MessageShow(Mo_MessageShow) , new SomeoneLeftChat(Mo_SomeoneLeftChat), new InformEjectFromChat(Mo_InformEjectFromChat), new CreateEmptyPrivateChat(Mo_CreateEmptyPrivateChat) , new InformJoinToPublicChat(Mo_InformJoinToPublicChat), new SomeoneJoinedChat(Mo_SomeoneJoinedChat), new InformFriendChangedStatus(Mo_InformFriendChangedStatus) , new ShowFormalMessage(Mo_ShowFormalMessage), new InformFriendListChanhged(Mo_InformFriendListChanhged), new InformCreatedPrivateChat(Mo_InformCreatedPrivateChat) , new ShowAnAgreementInvitation(Mo_ShowAnAgreementInvitation)); all_dialogs = new AllDiaogs(all_dialogs_delegates); all_chats = new AllChats(new SendChatMessage(Mo_SendChatMessage), new StartLeaveChatRequest(mo_StartLeaveChatRequest)); }
private void VerChat(Alumno alumno) { if (viewAllChats == null) { viewAllChats = new AllChats(); } ChatViewModel chatViewModel = new ChatViewModel(alumno.Clave, alumno.IdAlumno, m.IdMaestro); chatViewModel.NombreAlumno = alumno.Nombre; viewAllChats.BindingContext = chatViewModel; App.Current.MainPage.Navigation.PushAsync(viewAllChats); }
public Server(Dictionary <TypeOfDialog, Dictionary <int, Se_AuthDialog> > p_auth_dialogs , ref Dictionary <TypeOfDialog, Dictionary <int, Se_UnAuthDialog> > p_unauth_dialogs, Dictionary <int, PrivateChat> p_all_private_chats , Dictionary <int, PublicChat> p_all_public_chats, ref Dictionary <int, AddAgreement> p_all_add_agreements, Dictionary <int, UserData> p_all_users_logged_in, List <int> p_all_threads, SendToDistributerConstruct p_send_to_distributer_construct, object p_distributer_pulse_object) { Se_ServerDelegateForDialogs server_delegates_for_dialogs = new Se_ServerDelegateForDialogs(new GetFriendsList(Se_GetUserfriendList), new GetUserStatus(Se_GetUserStatus) , new GetPublicChatIds(Se_GetPublicChatIds), new GetOfflineMessages(Se_GetAllUserOfflineMessages), new GetAllAgreementInvitation(Se_GetAllUserAgreementInvitation) , new AuthSend(Se_Authsend), new IsLoggedIn(Se_IsLoggedIn), new UnAuthSend(Se_UnAuthSend), new IsThereUnauthWorkerThread(Se_IsThereUnauthWorkerThread) , new Login(Se_Login), new ServerInformChatLeave(Se_ServerInformChatLeave), new OnlineAreFriends(Se_OnlineAreFriends), new CreatePrivateChat(Se_CreatePrivateChat) , new IsTherePrivateChat(Se_IsTherePrivateChat), new StartClientCreatedPrivateChatInform(Se_StartClientCreatedPrivateChatInform) , new JoinPublicChatRequest(Se_JoinPublicChatRequest), new IsUserInPublicChat(Se_IsUserInPublicChat), new GetPublicChatUsersList(Se_GetPublicChatUsersList) , new CreateFormalMessageRequest(Se_CreateFormalMessageRequest), new IstherUser(Se_IstherUser), new CreateOfflineMessage(Se_CreateOfflineMessage) , new SignUp(Se_Signup), new CreateAddAgreement(Se_CreateAddAgreement), new GetAgreementAnswer(Se_GetAgreementAnswer), new OfflineMessagesReadInform(Se_OfflineMessagesReadInform) , new GetPrivateChatInvitationAnswer(Se_GetPrivateChaInvitationAnswer), new GetAUserAgreementInvitation(Se_DB_GetAUserAgreementInvitation)); server_core = new ServerCore(p_all_users_logged_in, new StartClientFriendChangedStatusInformDialog(Se_StartClientFriendChangedStatusInform) , new StartSendToClinetFormalMessage(Se_StartSendToClinetFormalMessage), p_all_threads, p_send_to_distributer_construct, p_distributer_pulse_object); all_dialogs = new AllDialogs(server_delegates_for_dialogs, ref p_auth_dialogs, ref p_unauth_dialogs); all_chats = new AllChats(p_all_private_chats, p_all_public_chats, new ChatSend(Se_ChatSend), new StartEjectedChatUserInform(Se_StartEjectedChatUserInform), new IsLoggedIn(Se_IsLoggedIn), new StartClientSomeoneJoinedChatInform(Se_StartClientSomeoneJoinedChatInform), new StartClientSomeoneLeftChatInform(Se_StartClientSomeoneLeftChatInform)); all_agreements = new AllAgreements(ref p_all_add_agreements, new CreateFormalMessageRequest(Se_CreateFormalMessageRequest), new DB_IsThereUser(Se_IstherUser) , new DB_AddToFriends(Se_AddToFriends), new DB_AreFriends(Se_AreFriends), new DB_CreateAddAgreement(Se_DB_CreateAddAgreement), new DB_RemoveAgreement(Se_RemoveAgreement) , new IsLoggedIn(Se_IsLoggedIn), new StartClientFriendListChangedInformDialog(Se_StartClientFriendListChangedInformDialog), new ReloadFriendList(Se_ReloadFriendList) , new GetOnlineUserFriendList(Se_GetOnlineUserFriendList), new GetUserStatus(Se_GetUserStatus), new AddAgreementDone(Se_AddAgreementDone) , new GetAllAdAgreements(Se_GetAllAdAgreements), new StartClientInvitedAgreementInform(Se_StartClientInvitedAgreementInform)); thread_works = new ThreadWorks(new RegisterThread(Se_RegisterThread), new IsThereUnauthWorkerThread(Se_IsThereUnauthWorkerThread) , new RemoveThread(Se_RemoveThread), new RemoveAThreadDialogs(Se_RemoveAThreadDialogs)); offline_user_works = new OfflineUserWorks(new ChangeStatusToOffline(Se_ChangeStatusToOffline), new OfflineUser(Se_OfflineUser), new GetUserPresenceState(Se_GetUserPresenceState) , new GetOnlineUserThreadID(Se_GetOnlineUserThreadID), new UserLeaveAllChats(Se_UserLeavAllChats), new RemoveAThreadDialogs(Se_RemoveAThreadDialogs) , new RemoveAUserDialogs(Se_RemoveAUserDialogs), new RemoveThread(Se_RemoveThread)); authenicate_and_distribute = new AuthenticateAndDistribute(new GetAThreadUserName(Se_GetAThreadUserName), new IsThereUnauthWorkerThread(Se_IsThereUnauthWorkerThread) , new DialogReceiveMessage(Se_DialogReceiveMessage), new ChatReceiveMessage(Se_ChatReceiveMessage), new MakeMessagesOffline(Se_MakeMessagesOffline) , new UserOfflineRequest(Se_UserOfflineRequest), new ThreadisLoggedIn(Se_ThreadIsLoggedIn), new RegisterAThreadRequest(Se_RegisterAThreadRequest) , new ThreadRemoveWorks(Se_ThreadRemoveWorks)); }
public bool IsExistChatWithSamePeaple(List <IClientModel> users, ChatType chatType) { var allChats = AllChats.Where(c => c.ChatType == chatType).ToList(); if (allChats.Count() == 0) { return(false); } foreach (var chat in allChats) { foreach (var client in users) { if (!chat.IsClientExistInChat(client)) { return(false); } } } return(true); }
public List <ChatModule> GetAllChatByType(ChatType chatType) { return(AllChats.Where(c => c.ChatType == chatType).ToList()); }
public List <ChatModule> GetAllChatThatClientExist(string name) { return(AllChats.Where(c => c.IsClientExistInChat(name)).ToList()); }
public ChatModule GetChatById(string chatId) { return(AllChats.FirstOrDefault(chat => chat.ChatId == chatId)); }
public bool IsExistChatWithName(string groupName) { var allGroupChats = AllChats.Where(c => c.ChatType == ChatType.Group).ToList(); return(allGroupChats.Any(g => ((GroupChat)g).GroupName == groupName)); }
public GroupChat GetGroupByName(string groupName) { var allGroupChats = AllChats.Where(c => c.ChatType == ChatType.Group).ToList(); return((GroupChat)allGroupChats.FirstOrDefault(g => ((GroupChat)g).GroupName == groupName)); }
public void AddChat(ChatModule chat) { AllChats.Add(chat); }
public Boolean saveInDb(Message msg) { var model = new VendorChat(); var vendorid = 0; if (msg.VendorId == 0) { vendorid = db.Products.Where(x => x.Id == msg.ProductId).FirstOrDefault().VendorId; } else { vendorid = msg.VendorId; } model = db.VendorChat.Where(x => x.IsActive == true && x.IsArchieved == false && x.VendorId == vendorid && x.ProductVariantDetailId == msg.ProductVariantDetailId && x.CustomerId == msg.CustomerId).FirstOrDefault(); if (model == null) { model = new VendorChat(); model.CustomerId = msg.CustomerId; model.IsActive = true; model.ProductVariantDetailId = msg.ProductVariantDetailId; model.IpAddress = msg.IpAddress; model.VendorId = vendorid; model.IsArchieved = false; model.ProductVariantDetailId = msg.ProductVariantDetailId; db.VendorChat.Add(model); } try { db.SaveChanges(); var data = new VendorChatMsg(); data.CustomerMsg = msg.CustomerMsg; data.DateTime = DateTime.Now; data.IsCustomerRead = false; data.IsVendorRead = false; data.VendorChatId = model.Id; data.VendorMsg = msg.VendorMsg; db.VendorChatMsg.Add(data); db.SaveChanges(); var chat = new AllChats(); chat.CustomerId = model.CustomerId; var cust = db.Users.Where(x => x.Id == model.CustomerId).FirstOrDefault(); chat.CustomerName = cust.FirstName + " " + cust.LastName; var vendor = db.Users.Where(x => x.Id == model.VendorId).FirstOrDefault(); chat.VendorName = vendor.DisplayName; chat.Date = data.DateTime; chat.LastMsg = data.CustomerMsg; chat.ProductId = msg.ProductId; chat.ProductVariantDetailId = model.ProductVariantDetailId; chat.VendorId = model.VendorId; if (msg.VendorId == 0) { var booldata = saveNotification(chat); } else { var bdata = saveNotiForCust(chat); } return(true); } catch (Exception ex) { return(false); } }
public void RemoveChat(ChatModule chat) { AllChats.Remove(chat); }