Exemplo n.º 1
0
        async Task Remove(ViewContact contact)
        {
            var deleteResult = await httpClient.DeleteAsync($"/api/contacts/{contact.Id}");

            deleteResult.EnsureSuccessStatusCode();
            Items.Remove(contact);
            await InvokeAsync(StateHasChanged);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IList <ViewContact> > > GetContactsByOrganization()
        {
            var profileOrg = await _UnitOfWork.ContactRepository.GetOrganization(User.NameIdentifier());

            if (profileOrg == null)
            {
                return(BadRequest());
            }

            var profiles = await _UnitOfWork.ContactRepository.GetProfilesByOrganization(profileOrg.OrganizationId);

            var userIds = profiles.Select(p => p.ContactId);

            ApplicationUser user  = null;
            IList <Contact> links = new List <Contact>();

            if (User.Identity.IsAuthenticated)
            {
                user = await _userManager.FindByIdAsync(User.NameIdentifier());

                links = await _UnitOfWork.ContactRepository.GetContacts(user.Id);
            }

            var suggestions = await _userManager?.Users.Where(c => userIds.Contains(c.Id) && c.Id != user.Id).ToListAsync();

            if (suggestions == null)
            {
                return(NotFound());
            }

            var contacts = new List <ViewContact>();


            foreach (var suggestion in suggestions)
            {
                Contact link = null;

                if (user != null && links != null)
                {
                    link = links.FirstOrDefault(l => l.UserId == suggestion.Id && l.OwnerId == user.Id);
                }

                var item = new ViewContact(user, suggestion, link);
                item.Contact.NumberOfContacts       = (await _UnitOfWork.ContactRepository.GetContacts(item.Contact.Id)).Count;
                item.Contact.SocialNetworkConnected = await _UnitOfWork.SocialNetworkRepository.GetSocialNetworkLinks(item.Contact.Id);

                item.Contact.CustomLinks = await _UnitOfWork.CustomLinkRepository.GetCustomLinkLinks(item.Contact.Id);

                item.Contact.NumberOfAds = (await _UnitOfWork.AdRepository.GetVisibledUser(item.Contact.Id)).Count;

                contacts.Add(item);
            }

            return(Ok(contacts));
        }
Exemplo n.º 3
0
        public ActionResult Contact()
        {
            ViewContact data = new ViewContact();

            if (this.ActiveUser != null)
            {
                data.Nickname = this.ActiveUser.Nickname;
                data.Email    = this.ActiveUser.Email;
            }

            return(this.View(data));
        }
Exemplo n.º 4
0
        private async Task Add(ViewContact contact)
        {
            var response = await httpClient.GetAsync($"/api/Contacts/add/{contact.Contact.Id}");

            response.EnsureSuccessStatusCode();

            var json = await response.Content.ReadAsStringAsync();

            var contactViewModel = JsonConvert.DeserializeObject <ContactViewModel>(json);

            contact.UserAccepted = Shared.ReferentielTable.EnumUserAccepted.PENDING;
            await InvokeAsync(StateHasChanged);

            await NotificationClient.SendNotificationsToUser(contactViewModel.Notification, contact.UserId);
        }
Exemplo n.º 5
0
        private void UpdateContact()
        {
            var contact = new ViewContact
            {
                Id          = this.Id,
                FirstName   = this.FirstName,
                LastName    = this.LastName,
                PhoneNumber = this.PhoneNumber
            };

            ContactService.UpdateContact(contact);

            Contacts = ContactService.GetCollection();
            OnPropertyChanged("Contacts");
            Navigation.PopAsync();
        }
Exemplo n.º 6
0
        public ActionResult Contact(ViewContact data)
        {
            MailMessage message = new MailMessage(new MailAddress(ComicConfigSectionGroup.Smtp.From), new MailAddress(ComicConfigSectionGroup.Smtp.From));

            message.Subject = "Comic Mashup Contact Submission";
            message.Body    = String.Format("From: {0}\nMessage: {1}", data.Email, data.Message);

            SmtpClient client = new SmtpClient(ComicConfigSectionGroup.Smtp.Server, ComicConfigSectionGroup.Smtp.Port);

            client.EnableSsl             = true;
            client.UseDefaultCredentials = false;
            client.Credentials           = new NetworkCredential(ComicConfigSectionGroup.Smtp.Username, ComicConfigSectionGroup.Smtp.Password);

            client.Send(message);

            return(this.RedirectToAction("ContactConfirm"));
        }
Exemplo n.º 7
0
        public async Task <ActionResult <IList <ViewContact> > > GetContactsByCountry(string countryEacode)
        {
            var suggestions = await _userManager?.Users.Where(c => c.Country.Equals(countryEacode)).ToListAsync();

            if (suggestions == null)
            {
                return(NotFound());
            }

            var contacts = new List <ViewContact>();

            ApplicationUser user  = null;
            IList <Contact> links = new List <Contact>();

            if (User.Identity.IsAuthenticated)
            {
                user = await _userManager.FindByIdAsync(User.NameIdentifier());

                links = await _UnitOfWork.ContactRepository.GetContacts(user.Id);
            }

            foreach (var suggestion in suggestions)
            {
                Contact link = null;

                if (user != null && links != null)
                {
                    link = links.FirstOrDefault(l => l.UserId == suggestion.Id && l.OwnerId == user.Id);
                }

                var item = new ViewContact(user, suggestion, link);
                item.Contact.NumberOfContacts       = (await _UnitOfWork.ContactRepository.GetContacts(item.Contact.Id)).Count;
                item.Contact.SocialNetworkConnected = await _UnitOfWork.SocialNetworkRepository.GetSocialNetworkLinks(item.Contact.Id);

                item.Contact.CustomLinks = await _UnitOfWork.CustomLinkRepository.GetCustomLinkLinks(item.Contact.Id);

                item.Contact.NumberOfAds = (await _UnitOfWork.AdRepository.GetVisibledUser(item.Contact.Id)).Count;

                contacts.Add(item);
            }

            return(Ok(contacts));
        }
Exemplo n.º 8
0
        public async Task <ActionResult <IEnumerable <ViewContact> > > GetSuggestion(string term, string filter)
        {
            if (string.IsNullOrEmpty(term))
            {
                return(BadRequest());
            }

            var user = await _userManager.FindByIdAsync(User.NameIdentifier());

            var suggestions = await Task.Run(() => _userManager?.Users.ToList().Where(c => c.EmailConfirmed && (filter == null || c.Country == filter) &&
                                                                                      (c.FirstName != null && c.FirstName.Contains(term, StringComparison.OrdinalIgnoreCase) ||
                                                                                       c.LastName != null && c.LastName.Contains(term, StringComparison.OrdinalIgnoreCase) ||
                                                                                       c.Description != null && c.Description.Contains(term, StringComparison.OrdinalIgnoreCase) ||
                                                                                       c.DisplayName != null && c.DisplayName.Contains(term, StringComparison.OrdinalIgnoreCase) ||
                                                                                       c.Email != null && c.Email.Contains(term, StringComparison.OrdinalIgnoreCase) ||
                                                                                       c.Title != null && c.Title.Contains(term, StringComparison.OrdinalIgnoreCase))));

            if (suggestions == null)
            {
                return(NotFound());
            }

            List <ViewContact> contacts = new();
            var allUserContacts         = await _UnitOfWork.ContactRepository.Where(x => x.UserId == User.NameIdentifier() || x.OwnerId == User.NameIdentifier());

            suggestions = suggestions.Where(u => !allUserContacts.Any(c => u.Id == c.OwnerId || u.Id == c.UserId || u.Id == User.NameIdentifier())).ToList();

            foreach (var suggestion in suggestions)
            {
                if (suggestion.Id == user.Id)
                {
                    continue;
                }

                var item = new ViewContact(user, suggestion);
                item.Contact.NumberOfContacts = (await _UnitOfWork.ContactRepository.GetContacts(item.Contact.Id)).Count;
                item.Contact.NumberOfAds      = (await _UnitOfWork.AdRepository.GetVisibledUser(item.Contact.Id)).Count;
                contacts.Add(item);
            }

            return(Ok(contacts));
        }
Exemplo n.º 9
0
        protected async Task OpenChat(ViewContact item)
        {
            var response = await httpClient.GetAsync($"/api/Tchat/{item.UserId}");

            response.EnsureSuccessStatusCode();
            StateTchatContainer.ListMessage.Clear();
            var json = await response.Content.ReadAsStringAsync();

            if (!string.IsNullOrEmpty(json))
            {
                StateTchatContainer.ListMessage.AddRange(JsonConvert.DeserializeObject <List <Message> >(json));
            }

            StateTchatContainer.ContactSelected = item;
            var tmp = StateTchatContainer.MyContacts.FirstOrDefault(x => x.UserId == item.UserId);

            tmp.HasNewMsg = false;

            StateTchatContainer.SetModalTchat(true);

            await ScrollToElementId("msg_card_body");
        }
Exemplo n.º 10
0
 public object Any(ViewContact request) => new PageResult(Request.GetPage("/contact"));
Exemplo n.º 11
0
 public void SetMyContacts(ViewContact value)
 {
     MyContacts.Add(value);
     NotifyStateChanged();
 }