Ejemplo n.º 1
0
        public ActionResult Index()
        {
            if (!IsLoggedIn())
            {
                return(RedirectToAction("Index", "Home"));
            }
            var currentAccount  = (Account)Session["Loggedin_Account"];
            var loggedInAccount = _accountRepository.GetById(currentAccount.Id);

            var chatModel = new ChatListViewModel
            {
                GroupChats   = _groupChatRepository.GetWhere(gc => gc.Paricipants.Select(p => p.Id).Contains(loggedInAccount.Id)).ToList(),
                PrivateChats = _privateChatRepository.GetWhere(pc => pc.FirstUser.Id == loggedInAccount.Id || pc.SecondUser.Id == loggedInAccount.Id).ToList()
            };

            foreach (var gc in chatModel.GroupChats)
            {
                var dbEntry = _groupChatRepository.GetById(gc.Id);
                gc.Paricipants = dbEntry.Paricipants;
            }

            foreach (var pc in chatModel.PrivateChats)
            {
                var dbEntry = _privateChatRepository.GetById(pc.Id);

                pc.FirstUser  = dbEntry.FirstUser;
                pc.SecondUser = dbEntry.SecondUser;
            }

            return(View(chatModel));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ChatViewModel    = EngineService.EngineInstance.ChatListViewModel;
            ContactViewModel = EngineService.EngineInstance.ContactListViewModel;

            base.OnCreate(savedInstanceState);
            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            imgProfile = FindViewById <ImageView>(Resource.Id.imgProfile);

            ViewContactUserId       = Intent.GetIntExtra(DETAIL_VIEW_USER_ID, 0);
            txtStatusLastUpdateDate = FindViewById <TextView>(Resource.Id.txtStatusLastUpdate);
            txtStatusContent        = FindViewById <TextView>(Resource.Id.txtStatusContent);
            txtUserName             = FindViewById <TextView>(Resource.Id.txtUserName);
            txtUserPhone            = FindViewById <TextView>(Resource.Id.txtUserPhone);
            txtUserEmail            = FindViewById <TextView>(Resource.Id.txtUserEmail);
            imgPhone = FindViewById <ImageView>(Resource.Id.imgPhone);
            imgEmail = FindViewById <ImageView>(Resource.Id.imgEmail);
            btBlock  = FindViewById <Button>(Resource.Id.btBlock);
            fab      = FindViewById <FloatingActionButton>(Resource.Id.fab);

            btChat        = FindViewById <Button>(Resource.Id.btStartChat);
            btCall        = FindViewById <Button>(Resource.Id.btCall);
            btChat.Click += BtChat_Click;
        }
Ejemplo n.º 3
0
        public ActionResult SelectTopic(string topicname, int page = 1 /*int topicid*/)
        {
            Session["topicname"] = topicname;
            //SelectTopicId = repository.GetTopicName(topicname).TopicId;

            ChatListViewModel model = new ChatListViewModel
            {
                GetComments = repository.GetComments()
                              .Where(p => topicname == null || p.ComTopicId == SelectTopicId)
                              .OrderBy(p => p.CommentId)
                              .Skip((page - 1) * PageCom)
                              .Take(PageCom),
                PagingInfoCom = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageCom,
                    TotalItems   = topicname == null?
                                   repository.GetComments().Count() :
                                       repository.GetComments().Where(e => e.ComTopicName == topicname).Count()
                },
                CurrentTopicName = topicname
            };

            //ViewBag.SelectTopicName = repository.GetTopicName(topicname).TopicName;


            return(RedirectToAction("Chat"));
        }
Ejemplo n.º 4
0
 public ChatModuleViewModel(
     ChatListViewModel chatList,
     ChatInteractivityViewModel chatInteractivity)
 {
     this.ChatList          = chatList;
     this.ChatInteractivity = chatInteractivity;
 }
Ejemplo n.º 5
0
        public ActionResult _Send(ChatListViewModel com, string returnUrl, int page = 1)
        {
            string topicname = com.CurrentTopicName;

            SelectTopicId = repository.GetTopicName(topicname).TopicId;
            repository.CreateComment(com.Content, SelectTopicId, User.Identity.Name);
            ChatListViewModel model = new ChatListViewModel
            {
                TopicId     = SelectTopicId,
                GetComments = repository.GetComments()
                              .Where(p => topicname == null || p.ComTopicId == SelectTopicId)
                              .OrderBy(p => p.CommentId)
                              .Skip((page - 1) * PageCom)
                              .Take(PageCom),
                PagingInfoCom = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageCom,
                    TotalItems   = topicname == null?
                                   repository.GetComments().Count() :
                                       repository.GetComments().Where(e => e.ComTopicName == topicname).Count()
                },
                CurrentTopicName = topicname,
                Autor            = User.Identity.Name
            };

            ViewBag.SelectTopicName = repository.GetTopicName(topicname).TopicName;

            // var coment = repository.GetComments();
            //return View(model);
            return(RedirectToAction("Chat", "Chat"));
        }
Ejemplo n.º 6
0
        public ViewResult Chat(/*ChatListViewModel modelstringstring topicname, */ int page = 1)
        {
            if (Session["topicname"] == null)
            {
                Session["topicname"] = repository.GetTopics().First();
            }
            string topicname = (string)Session["topicname"];

            SelectTopicId = repository.GetTopicName(topicname).TopicId;

            ChatListViewModel model = new ChatListViewModel
            {
                GetComments = repository.GetComments()
                              .Where(p => topicname == null || p.ComTopicId == SelectTopicId)
                              .OrderBy(p => p.CommentId)
                              .Skip((page - 1) * PageCom)
                              .Take(PageCom),
                PagingInfoCom = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageCom,
                    TotalItems   = topicname == null?
                                   repository.GetComments().Count() :
                                       repository.GetComments().Where(e => e.ComTopicName == topicname).Count()
                },
                CurrentTopicName = topicname
            };

            ViewBag.SelectTopicName = repository.GetTopicName(topicname).TopicName;


            return(View(model));
        }
Ejemplo n.º 7
0
        public ChatListAdapter(Activity ParentActivity, ChatListViewModel ViewModel)
        {
            this.ParentActivity = ParentActivity;
            this.ViewModel      = ViewModel;

            ViewModel.PrivateChatEntryCollection.CollectionChanged += (sender, args) =>
            {
                this.ParentActivity.RunOnUiThread(NotifyDataSetChanged);
            };
        }
Ejemplo n.º 8
0
        public ActionResult Chats()
        {
            ChatListViewModel model = new ChatListViewModel();

            model.currentUser = accountService.getUserByName(User.Identity.Name);
            model.userChats   = chatService.GetChatsByUser(model.currentUser);

            //user can initiate a chat with those he is following
            model.availableChatUsers = accountService.getFollowingByUser(model.currentUser);
            model.usersChattingWith  = chatService.getUsersChattingWithByUser(model.currentUser);

            return(View(model));
        }
Ejemplo n.º 9
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     if (App.IsNotificationRecieved)
     {
         MessagingCenter.Send("5", "NotificationRecieved");
     }
     else
     {
         MessagingCenter.Send(string.Empty, "NotificationRecieved");
     }
     BindingContext = new ChatListViewModel(navigation: Navigation);
 }
Ejemplo n.º 10
0
 void InitChatViewService()
 {
     if (EngineService.EngineInstance.ChatListViewModel != null)
     {
         ViewModel           = EngineService.EngineInstance.ChatListViewModel;
         ViewModel.IAmTyping = new Model.Chat.TypingStatus()
         {
             IsTyping    = false,
             MyUserId    = ViewModel.CurrentlyOpenDTO.MyUserId,
             OtherUserId = ViewModel.CurrentlyOpenDTO.OtherUserId,
             ThreadId    = ViewModel.CurrentlyOpenDTO.EntryID
         };
         ViewModel.PrivateChatHistoryCollection.Clear();
     }
 }
Ejemplo n.º 11
0
        public ActionResult Index()
        {
            var chats        = new ChatListViewModel(userManager.GetRoles(User.Identity.GetUserId()));
            var chatEntities =
                chatRepository.Where(l => l.LeadType == "Chat")
                .Include(c => c.Interaction)
                .Include(c => c.Property)
                .AsNoTracking()
                .OrderByDescending(c => c.Date);

            foreach (var chatItemInRepository in chatEntities)
            {
                var chatViewModel = new ChatViewModel();
                chatViewModel.Id       = chatItemInRepository.Id;
                chatViewModel.ClientId = chatItemInRepository.ClientId;

                chatViewModel.Date = serverTime.ConvertServerTimeToStandardUserTime(chatItemInRepository.Date);
                if (chatItemInRepository.HasProperty("Description"))
                {
                    var description = chatItemInRepository.GetProperty("Description").Value;
                    if (description.Length > 60)
                    {
                        chatViewModel.Description = description.Substring(0, 57) + "...";
                    }
                    else
                    {
                        chatViewModel.Description = description;
                    }
                }
                if (chatItemInRepository.HasProperty("Email"))
                {
                    chatViewModel.Email = chatItemInRepository.GetProperty("Email").Value;
                }
                if (chatItemInRepository.HasProperty("Phone"))
                {
                    chatViewModel.Phone = chatItemInRepository.GetProperty("Phone").Value;
                }

                chatViewModel.ClientName = clientRepository.Where(cr => cr.Id == chatItemInRepository.ClientId).First().Name;
                chats.Collection.Add(chatViewModel);
            }
            return(View(chats));
        }
Ejemplo n.º 12
0
 void InitViewModels()
 {
     if (ContactListViewModel == null)
     {
         ContactListViewModel = new ContactListViewModel();
     }
     if (ChatListViewModel == null)
     {
         ChatListViewModel = new ChatListViewModel();
     }
     if (GroupListViewModel == null)
     {
         GroupListViewModel = new GroupListViewModel();
     }
     if (ProfileViewModel == null)
     {
         ProfileViewModel = new ProfileViewModel();
     }
 }
Ejemplo n.º 13
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            PrivateChatViewModel = EngineService.EngineInstance.ChatListViewModel;
            GroupChatViewModel   = EngineService.EngineInstance.GroupListViewModel;
            MyProfileViewModel   = EngineService.EngineInstance.ProfileViewModel;

            var rootView = inflater.Inflate(Resource.Layout.fragment_setting, container, false);

            btChatWallPaper = rootView.FindViewById <Button>(Resource.Id.btChatWallPaper);
            //btNotification = rootView.FindViewById<Button>(Resource.Id.btNotification);
            btClearAll = rootView.FindViewById <Button>(Resource.Id.btClearAll);
            btLang     = rootView.FindViewById <Button>(Resource.Id.btChangeLang);

            btChatWallPaper.Click += BtChatWallPaper_Click;
            //btNotification.Click += BtNotification_Click;
            btClearAll.Click += BtClearAll_Click;
            btLang.Click     += BtLang_Click;

            InitViewLangs();
            return(rootView);
        }
        protected override void OnStart()
        {
            base.OnStart();
            if (ChatViewModel == null)
            {
                EngineService.EngineInstance.ChatListViewModel = new ChatListViewModel();
                ChatViewModel = new ChatListViewModel();
            }

            if (ContactViewModel == null)
            {
                EngineService.EngineInstance.ContactListViewModel = new ContactListViewModel();
                ContactViewModel = new ContactListViewModel();
            }

            if (ChatViewModel.PrivateChatEntryCollection.Count == 0 && CrossConnectivity.Current.IsConnected)
            {
                GetPrivateChatEntryRequest request = new GetPrivateChatEntryRequest()
                {
                    MY_USER_ID = MyApplication.Me.USERID,
                    TOKEN      = MyApplication.Me.TOKEN
                };
                ChatViewModel.LoadAllChatEntryItemCommand.Execute(request);
            }
            ChatViewModel.PropertyChanged += ViewModel_PropertyChanged;
            if (ContactViewModel.CurrentOpenContactDTO == null)
            {
                ContactViewModel.LoadContactItemCommand.Execute(new GetProfileRequest()
                {
                    TOKEN = MyApplication.Me.TOKEN, USERID = Convert.ToString(ViewContactUserId)
                });
            }
            else
            {
                SetDataContent();
            }
            ContactViewModel.PropertyChanged += ContactViewModel_PropertyChanged;
        }
Ejemplo n.º 15
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (EngineService.EngineInstance.ChatListViewModel == null)
            {
                EngineService.EngineInstance.ChatListViewModel = new ChatListViewModel();
            }
            ChatListViewModel = EngineService.EngineInstance.ChatListViewModel;

            var rootView = inflater.Inflate(Resource.Layout.fragment_chat, container, false);

            recycler     = rootView.FindViewById <RecyclerView>(Resource.Id.recycleChatHistory);
            fabAdd       = rootView.FindViewById <FloatingActionButton>(Resource.Id.fabAddChat);
            swipeRefresh = rootView.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefresh);
            InitSwipeRefreshLayout(swipeRefresh);

            recycler.HasFixedSize = true;
            recycler.SetLayoutManager(new LinearLayoutManager(this.Context, LinearLayoutManager.Vertical, false));
            recycler.SetItemAnimator(new DefaultItemAnimator());

            Adapter = new ChatListAdapter(Activity, ChatListViewModel);
            recycler.SetAdapter(Adapter);

            InitRecyclerScrollListener(recycler, (e) => {
                if (e && fabAdd.IsShown)
                {
                    fabAdd.Hide();
                }
                else if (!e && !fabAdd.IsShown)
                {
                    fabAdd.Show();
                }
            });

            fabAdd.Click += (sender, e) => {
                ParentActivity.SetTabAndFragment(MainActivity.FRAGMENT_TYPE.FRAGMENT_CONTACT);
            };
            return(rootView);
        }
Ejemplo n.º 16
0
 public ChatListView(ChatListViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Ejemplo n.º 17
0
 public ChatDetailAdapter(ChatDetailView ParentActivity, ChatListViewModel ViewModel, UserDTO Me)
 {
     this.ParentActivity = ParentActivity;
     this.ViewModel      = ViewModel;
     this.Me             = Me;
 }
Ejemplo n.º 18
0
 public ChatListPage()
 {
     InitializeComponent();
     BindingContext = new ChatListViewModel();
 }
Ejemplo n.º 19
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     BindingContext = new ChatListViewModel(navigation: Navigation);
 }