Exemple #1
0
        public SearchAccount GetDatasFriend(int friendId)
        {
            Account friend = _context.Accounts.Find(friendId);

            if (friend != null)
            {
                SearchAccount searchItem = new SearchAccount(); //result model

                searchItem.Id         = friend.Id;
                searchItem.Friendship = FriendshipStatus.Accepted;
                searchItem.Label      = friend.Fullname;
                searchItem.Img        = friend.ProfileImg;
                searchItem.Email      = friend.Email;
                searchItem.Phone      = friend.Phone;
                searchItem.Birthday   = friend.Birthday;
                searchItem.Address    = friend.Address;
                searchItem.Website    = friend.Website;
                searchItem.StatusText = friend.StatusText;

                AccountSocialLink accountSocials = _context.AccountSocialLinks.FirstOrDefault(a => a.AccountId == friendId);

                searchItem.Facebook  = accountSocials.Facebook;
                searchItem.Twitter   = accountSocials.Twitter;
                searchItem.Instagram = accountSocials.Instagram;
                searchItem.Linkedin  = accountSocials.Linkedin;

                return(searchItem);
            }

            return(null);
        }
Exemple #2
0
 public void UpdateSocialLink(AccountSocialLink updatesociallink, AccountSocialLink socialLink)
 {
     updatesociallink.Facebook  = socialLink.Facebook;
     updatesociallink.Instagram = socialLink.Instagram;
     updatesociallink.Linkedin  = socialLink.Linkedin;
     updatesociallink.Twitter   = socialLink.Twitter;
     _context.SaveChanges();
 }
Exemple #3
0
        public IActionResult FriendSocialLinks(int friendId)
        {
            AccountSocialLink friendsocials = _friendsRepository.GetFriendSocialLinks(friendId);

            if (friendsocials != null)
            {
                return(Ok(friendsocials));
            }
            ;

            return(Ok(StatusCode(404)));
        }
Exemple #4
0
        public AccountSocialLink GetPublicSocialLinks(int id)
        {
            Account           account        = _context.Accounts.Find(id);
            AccountPrivacy    accountPrivacy = _context.AccountPrivacies.FirstOrDefault(p => p.AccountId == account.Id);
            AccountSocialLink accountSocial  = _context.AccountSocialLinks.FirstOrDefault(s => s.AccountId == account.Id);

            if (accountPrivacy.SocialLink)
            {
                return(accountSocial);
            }
            else
            {
                accountSocial.Facebook  = null;
                accountSocial.Twitter   = null;
                accountSocial.Instagram = null;
                accountSocial.Linkedin  = null;

                return(accountSocial);
            }
        }
        public IActionResult SignUp(RegisterViewModel model)
        {
            bool checkUser = _authRepository.CheckEmail(model.Email);
            bool number = _authRepository.CheckPhone(model.Phone);

            if (checkUser)
            {
                ModelState.AddModelError("Email", "Bu E-mail artiq movcuddur");
            }
            if (number)
            {
                ModelState.AddModelError("Phone", "Bu Nömrə artıq mövcuddur");
            }
            if (ModelState.IsValid)
            {
                var user = _mapper.Map<RegisterViewModel, Account>(model);
                user.Fullname = model.Name + " " + model.Surname;
                user.Token = Guid.NewGuid().ToString();
                user.Status = true;
                user.IsEmailVerified = false;

                //email verification code
                user.EmailActivationCode = Guid.NewGuid().ToString();

                _authRepository.Register(user);

                AccountSocialLink accountSocialLink = new AccountSocialLink
                {
                    AccountId = user.Id,
                    Status = true,
                    AddedBy = "System",
                    AddedDate = DateTime.Now
                };
                _authRepository.AddedSocial(accountSocialLink);

                //creating account's privacy Database
                AccountPrivacy accountPrivacy = new AccountPrivacy
                {
                    AccountId = user.Id,
                    Status = true,
                    AddedDate = DateTime.Now,
                    AddedBy = "System",
                    Phone = true,
                    Email = true,
                    LastLogin = true,
                    LastSeen = true,
                    Address = true,
                    Birthday = true,
                    ProfileImg = true,
                    SocialLink = true,
                    StatusText = true,
                    Website = true
                };
                _authRepository.CreatePrivacy(accountPrivacy);

                AccountSecurity accountSecurity = new AccountSecurity
                {
                    AccountId=user.Id,
                    TwoFactoryAuth = false,
                    LoginAlerts = false
                };
                _authRepository.CreateSecurity(accountSecurity);

                //send verification link email
                string userFullname = user.Name + " " + user.Surname;

                string link = HttpContext.Request.Scheme + "://" + Request.Host + "/account/verifyemail/" + user.EmailActivationCode;

                _emailService.VerificationEmail(user.Email, link, user.EmailActivationCode, userFullname);

                Response.Cookies.Append("token", user.Token, new Microsoft.AspNetCore.Http.CookieOptions
                {
                    HttpOnly = true,
                    Expires = DateTime.Now.AddYears(1)
                });

                return RedirectToAction("chat1", "pages");
            }

            return View(model);
        }
Exemple #6
0
        public SearchAccount GetDatasPublic(int currentAccountId, int accountId)
        {
            Account        account        = _context.Accounts.Find(accountId);
            AccountPrivacy accountPrivacy = _context.AccountPrivacies.FirstOrDefault(p => p.AccountId == account.Id);

            if (accountPrivacy != null)
            {
                SearchAccount searchItem = new SearchAccount();
                //id
                searchItem.Id = account.Id;
                //fullname
                searchItem.Label = account.Fullname;
                //friendship

                //FriendshipStatus friendshipStatus = _friendsRepository.GetFriendshipStatus(currentAccountId, accountId);
                Friend friendship = _friendsRepository.GetFriendship(currentAccountId, accountId);

                if (friendship != null)
                {
                    if (friendship.StatusCode != FriendshipStatus.Error)
                    {
                        searchItem.Friendship = friendship.StatusCode;
                    }
                    if (friendship.FromUserId == currentAccountId)
                    {
                        searchItem.IsFriendRequestSender = true;
                    }
                }
                else
                {
                    //static for if error ocoured
                    searchItem.Friendship = FriendshipStatus.NotFriend;
                }

                //email
                searchItem.Email = account.Email; // static public
                //address
                if (accountPrivacy.Address == false)
                {
                    searchItem.Address = null;
                }
                else
                {
                    searchItem.Address = account.Address;
                }
                //website
                if (accountPrivacy.Website == false)
                {
                    searchItem.Website = null;
                }
                else
                {
                    searchItem.Website = account.Website;
                }
                //birthday
                if (accountPrivacy.Birthday == false)
                {
                    searchItem.Birthday = null;
                }
                else
                {
                    searchItem.Birthday = account.Birthday;
                }
                //phone
                if (accountPrivacy.Phone == false)
                {
                    searchItem.Phone = null;
                }
                else
                {
                    searchItem.Phone = account.Phone;
                }
                //profile img
                if (accountPrivacy.ProfileImg == false)
                {
                    searchItem.Img = null;
                }
                else
                {
                    searchItem.Img = account.ProfileImg;
                }
                //status text
                if (accountPrivacy.StatusText == false)
                {
                    searchItem.StatusText = null;
                }
                else
                {
                    searchItem.StatusText = account.StatusText;
                }
                //social links
                if (accountPrivacy.SocialLink == false)
                {
                    searchItem.Facebook  = null;
                    searchItem.Twitter   = null;
                    searchItem.Instagram = null;
                    searchItem.Linkedin  = null;
                }
                else
                {
                    AccountSocialLink accountSocials = _context.AccountSocialLinks.FirstOrDefault(a => a.AccountId == accountId);

                    searchItem.Facebook  = accountSocials.Facebook;
                    searchItem.Twitter   = accountSocials.Twitter;
                    searchItem.Instagram = accountSocials.Instagram;
                    searchItem.Linkedin  = accountSocials.Linkedin;
                }
                //if (accountPrivacy.AcceptAllMessages == false) //PROBLEM!!!
                //{
                //
                //}

                return(searchItem);
            }
            return(null);
        }
 public void AddedSocial(AccountSocialLink accountSocialLink)
 {
     _context.AccountSocialLinks.Add(accountSocialLink);
     _context.SaveChanges();
 }
        public AccountSocialLink GetFriendSocialLinks(int friendId)
        {
            AccountSocialLink socialLinks = _context.AccountSocialLinks.FirstOrDefault(f => f.AccountId == friendId);

            return(socialLinks);
        }