Ejemplo n.º 1
0
        /// <summary>
        /// Modify ban's object.
        /// </summary>
        /// <param name="id">Ban's identeficator.</param>
        /// <param name="updateByUser">Updated by user flag.</param>
        /// <param name="userID">User's identeficator.</param>
        /// <param name="adminID">Admin's identeficator.</param>
        /// <param name="reason">Ban's reason.</param>
        /// <param name="fromDate">Ban's from date.</param>
        /// <param name="toDate">Ban's to date.</param>
        /// <param name="isDeleted">Logical deleting.</param>
        public static void ModifyBan(
            Guid?id,
            Boolean?updateByUser,
            Guid?userID,
            Guid?adminID,
            String reason,
            DateTime?fromDate,
            DateTime?toDate,
            Boolean?isDeleted)
        {
            ObjectParameter pkID = (id != null) ? new ObjectParameter("pkID", id)
                : new ObjectParameter("pkID", typeof(Guid));

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                record.spBan(
                    pkID,
                    updateByUser,
                    userID,
                    adminID,
                    reason,
                    fromDate,
                    toDate,
                    isDeleted
                    );
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get object of PersonalInfo.
        /// </summary>
        /// <param name="userID">Current user identificator.</param>
        /// <returns>PersonalInfo item.</returns>
        public static PersonalInfo GetUserInfo(Guid userID)
        {
            PersonalInfo personalInfo = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                personalInfo = record.PersonalInfoes
                               .Select(s => new PersonalInfo
                {
                    ID          = s.ID,
                    UserID      = s.UserID,
                    NickName    = s.NickName,
                    FirstName   = s.FirstName,
                    LastName    = s.LastName,
                    MiddleName  = s.MiddleName,
                    Sex         = s.Sex,
                    Phone       = s.Phone,
                    Birthday    = s.Birthday,
                    ImagePath   = s.ImagePath,
                    Description = s.Description
                })
                               .FirstOrDefault(f => f.UserID.Equals(userID));
            }

            return(personalInfo);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Set new status message.
 /// </summary>
 /// <param name="userID">User identificator.</param>
 /// <param name="message">Message content.</param>
 /// <param name="status">Type of status.</param>
 public static void SetStatusMessage(Guid userID, String message, UserStatus status)
 {
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         record.spInsStatus(userID, message, (Int32)status);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Get Address of current user.
        /// </summary>
        /// <param name="userID">User identificator.</param>
        /// <returns>Object Address.</returns>
        public static Address GetUserAddress(Guid userID)
        {
            Address address = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                address = record.Addresses
                          .Where(w => w.PersonalInfo.UserID == userID)
                          .Select(s => new Address
                {
                    ID         = s.ID,
                    UserInfoID = s.UserInfoID,
                    CountryID  = s.CountryID,
                    CityID     = s.CityID,
                    Area       = s.Area,
                    Street     = s.Street,
                    Home       = s.Home,
                    Apartment  = s.Apartment,
                    IsDeleted  = s.IsDeleted
                })
                          .FirstOrDefault(f => !f.IsDeleted);
            }

            return(address);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Modify user address information.
        /// </summary>
        /// <param name="id">Row itentify.</param>
        /// <param name="updateByUserInfo">Update by user id flag.</param>
        /// <param name="userID">User identify.</param>
        /// <param name="countryID">Country identify.</param>
        /// <param name="cityID">City identify.</param>
        /// <param name="area">Area name.</param>
        /// <param name="street">Street name.</param>
        /// <param name="home">Home address.</param>
        /// <param name="apartment">Apartment info.</param>
        public static void ModifyAddress(
            Guid?id,
            Boolean updateByUserInfo,
            Guid?userID,
            Guid?countryID,
            Guid?cityID,
            String area,
            String street,
            String home,
            String apartment)
        {
            ObjectParameter pkID = (id != null) ? new ObjectParameter("pkID", id)
                : new ObjectParameter("pkID", typeof(Guid));

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawUserInfoID = record.PersonalInfoes
                                    .FirstOrDefault(f => f.UserID == userID);
                Guid?userInfoID = (rawUserInfoID == null) ? Guid.Empty : rawUserInfoID.ID;

                record.spAddress(
                    pkID,
                    updateByUserInfo,
                    userInfoID,
                    countryID,
                    cityID,
                    area,
                    street,
                    home,
                    apartment,
                    false);
            }
        }
        /// <summary>
        /// Send message to wallboard.
        /// </summary>
        /// <param name="type">Content type (text, music, etc).</param>
        /// <param name="senderID">Who send message.</param>
        /// <param name="receiverID">Who receive message.</param>
        /// <param name="message">Message content.</param>
        public static void InsertMessage(WallBoardItemType type, Guid senderID, Guid receiverID, Object message)
        {
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                switch (type)
                {
                case WallBoardItemType.Text:
                {
                    record.spInsWallBoardTextMessage(
                        (Int32)WallBoardItemType.Text, senderID, receiverID, (String)message);
                }
                break;

                case WallBoardItemType.Image:
                {
                }
                break;

                case WallBoardItemType.Audio:
                {
                }
                break;

                case WallBoardItemType.Video:
                {
                }
                break;
                }
            }
        }
 /// <summary>
 /// Delete item from wallboard by item identifier.
 /// </summary>
 /// <param name="id">Item identificator.</param>
 public static void DeleteItem(Guid id)
 {
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         record.spDelWallBoardItem(id);
     }
 }
 /// <summary>
 /// Send message to wallboard.
 /// </summary>
 /// <param name="type">Content type (text, music, etc).</param>
 /// <param name="senderID">Who send message.</param>
 /// <param name="receiverID">Who receive message.</param>
 /// <param name="message">Message content.</param>
 public static void InsertMessage(WallBoardItemType type, Guid senderID, Guid receiverID, Object message)
 {
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         switch (type)
         {
             case WallBoardItemType.Text:
                 {
                     record.spInsWallBoardTextMessage(
                         (Int32)WallBoardItemType.Text, senderID, receiverID, (String)message);
                 }
                 break;
             case WallBoardItemType.Image:
                 {
                 }
                 break;
             case WallBoardItemType.Audio:
                 {
                 }
                 break;
             case WallBoardItemType.Video:
                 {
                 }
                 break;
         }
     }
 }
        /// <summary>
        /// Get object of PersonalInfo.
        /// </summary>
        /// <param name="userID">Current user identificator.</param>
        /// <returns>PersonalInfo item.</returns>
        public static PersonalInfo GetUserInfo(Guid userID)
        {
            PersonalInfo personalInfo = null;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                personalInfo = record.PersonalInfoes
                    .Select(s => new PersonalInfo
                        {
                            ID = s.ID,
                            UserID = s.UserID,
                            NickName = s.NickName,
                            FirstName = s.FirstName,
                            LastName = s.LastName,
                            MiddleName = s.MiddleName,
                            Sex = s.Sex,
                            Phone = s.Phone,
                            Birthday = s.Birthday,
                            ImagePath = s.ImagePath,
                            Description = s.Description
                        })
                    .FirstOrDefault(f => f.UserID.Equals(userID));
            }

            return personalInfo;
        }
 /// <summary>
 /// Delete item from wallboard by item identifier.
 /// </summary>
 /// <param name="id">Item identificator.</param>
 public static void DeleteItem(Guid id)
 {
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         record.spDelWallBoardItem(id);
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Set new status message.
 /// </summary>
 /// <param name="userID">User identificator.</param>
 /// <param name="message">Message content.</param>
 /// <param name="status">Type of status.</param>
 public static void SetStatusMessage(Guid userID, String message, UserStatus status)
 {
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         record.spInsStatus(userID, message, (Int32)status);
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Get user's friends with needled params.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="startRow"></param>
        /// <param name="rowCount"></param>
        /// <returns></returns>
        public static IEnumerable <Friend> GetUserFriendsWithParams(Guid userID, Int32 startRow, Int32 rowCount, bool online)
        {
            IEnumerable <Friend> recordList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                recordList = record.Friends
                             .Where(w => w.UserID.Equals(userID) && !w.IsDeleted)
                             .Select(s => new Friend
                {
                    ID             = s.ID,
                    UserID         = s.UserID,
                    FriendID       = s.FriendID,
                    FriendshipDate = s.FriendshipDate,
                    IsDeleted      = s.IsDeleted
                }).OrderBy(o => o.FriendshipDate).Skip(startRow).Take(rowCount).ToList();
            }
            if (!online)
            {
                return(recordList);
            }
            else
            {
                return(recordList.Where(w => StatusRepository.GetStatusID(w.FriendID) != 0));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Set status 'read' to current message.
        /// </summary>
        /// <param name="messageID">Message identifier.</param>
        public static void SetReadStatus(Guid messageID)
        {
            ObjectParameter pkMessageID = new ObjectParameter("pkMessageID", messageID);

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                record.spMessage(pkMessageID, null, null, null, null, true, null, null);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Send message to another user.
        /// </summary>
        /// <param name="senderID">Sender identifier.</param>
        /// <param name="receiverID">Receiver identifier.</param>
        /// <param name="header">Message title.</param>
        /// <param name="text">Message text.</param>
        public static void SendPrivateMessage(Guid senderID, Guid receiverID, String header, String text)
        {
            ObjectParameter pkMessageID = new ObjectParameter("pkMessageID", typeof(Guid));

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                record.spMessage(pkMessageID, senderID, receiverID, header, text, true, false, false);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Get max privelege mask of role.
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public static Nullable <Int16> GetMaxPrivelegeMask(Guid userID)
 {
     System.Nullable <Int16> privelegeMask = 0;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         privelegeMask = record.spRoleGet(userID).Max(m => m.PrivilegeMask);
     }
     return(privelegeMask);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Get min privelege mask of role.
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public static Nullable<Int16> GetMinPrivelegeMask(Guid userID)
 {
     System.Nullable<Int16> privelegeMask = 0;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         privelegeMask = record.spRoleGet(userID).Min(m => m.PrivilegeMask);
     }
     return privelegeMask;
 }
Ejemplo n.º 17
0
        public static IEnumerable <SocialNetwork.DataAccess.UserRole> GetUserRoles(Guid userID)
        {
            IEnumerable <SocialNetwork.DataAccess.UserRole> userRoleList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                userRoleList = record.spRoleGet(userID).ToList();
            }
            return(userRoleList);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Get current status identifier.
        /// </summary>
        /// <param name="userID">User identificator.</param>
        /// <returns>Status code.</returns>
        public static Int32 GetStatusID(Guid userID)
        {
            Int32 statusID;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawStatus = record.Status.FirstOrDefault(f => f.UserID.Equals(userID) && f.IsSet && !f.IsDeleted);
                statusID = (rawStatus == null) ? (Int32)_defaultStatus : rawStatus.StatusID;
            }

            return statusID;
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Get user id from email & password.
 /// </summary>
 /// <param name="userEmail">User's email.</param>
 /// <param name="userPassword">User's password.</param>
 /// <returns>User identifier.</returns>
 public static Guid GetUserID(String userEmail, String userPassword)
 {
     Guid userID = Guid.Empty;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         var rawUserID = record.Users
             .FirstOrDefault(f => f.Email.Equals(userEmail) && f.Password.Equals(userPassword));
         userID = (rawUserID == null) ? Guid.Empty : rawUserID.UserID;
     }
     return userID;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Get user id from email & password.
        /// </summary>
        /// <param name="userEmail">User's email.</param>
        /// <param name="userPassword">User's password.</param>
        /// <returns>User identifier.</returns>
        public static Guid GetUserID(String userEmail, String userPassword)
        {
            Guid userID = Guid.Empty;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawUserID = record.Users
                                .FirstOrDefault(f => f.Email.Equals(userEmail) && f.Password.Equals(userPassword));
                userID = (rawUserID == null) ? Guid.Empty : rawUserID.UserID;
            }
            return(userID);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Get current status identifier.
        /// </summary>
        /// <param name="userID">User identificator.</param>
        /// <returns>Status code.</returns>
        public static Int32 GetStatusID(Guid userID)
        {
            Int32 statusID;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawStatus = record.Status.FirstOrDefault(f => f.UserID.Equals(userID) && f.IsSet && !f.IsDeleted);
                statusID = (rawStatus == null) ? (Int32)_defaultStatus : rawStatus.StatusID;
            }

            return(statusID);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Get current status message.
        /// </summary>
        /// <param name="userID">User identifier.</param>
        /// <returns>String with status message.</returns>
        public static String GetStatusMessage(Guid userID)
        {
            String statusMessage = String.Empty;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawStatusMessage = record.Status
                    .FirstOrDefault(f => f.UserID.Equals(userID) && f.IsSet && !f.IsDeleted);
                statusMessage = (rawStatusMessage == null) ? _defaultStatusMessage : rawStatusMessage.StatusMessage;
            }

            return statusMessage;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Get name of user city.
        /// </summary>
        /// <param name="cityID">City identificator.</param>
        /// <returns>City name.</returns>
        public static String GetCityName(Guid cityID)
        {
            String cityName = String.Empty;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawCity = record.Cities.FirstOrDefault(f => f.CityID == cityID);
                cityName = rawCity == null ? _defaultCityName : rawCity.Name;
            }

            return(cityName);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Get current status message.
        /// </summary>
        /// <param name="userID">User identifier.</param>
        /// <returns>String with status message.</returns>
        public static String GetStatusMessage(Guid userID)
        {
            String statusMessage = String.Empty;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawStatusMessage = record.Status
                                       .FirstOrDefault(f => f.UserID.Equals(userID) && f.IsSet && !f.IsDeleted);
                statusMessage = (rawStatusMessage == null) ? _defaultStatusMessage : rawStatusMessage.StatusMessage;
            }

            return(statusMessage);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Delete private message.
        /// </summary>
        /// <param name="messageID">Message identifier.</param>
        /// <param name="type">Type of message (sended or received).</param>
        public static void DeletePrivateMessage(Guid messageID, MessageType type)
        {
            ObjectParameter pkMessageID = new ObjectParameter("pkMessageID", messageID);

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                if (type == MessageType.Posted)
                {
                    record.spMessage(pkMessageID, null, null, null, null, null, true, null);
                }
                else
                {
                    record.spMessage(pkMessageID, null, null, null, null, null, null, true);
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Delete private message.
        /// </summary>
        /// <param name="messageID">Message identifier.</param>
        /// <param name="type">Type of message (sended or received).</param>
        public static void DeletePrivateMessage(Guid messageID, MessageType type)
        {
            ObjectParameter pkMessageID = new ObjectParameter("pkMessageID", messageID);

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                if (type == MessageType.Posted)
                {
                    record.spMessage(pkMessageID, null, null, null, null, null, true, null);
                }
                else
                {
                    record.spMessage(pkMessageID, null, null, null, null, null, null, true);
                }
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Get all user roles on server.
 /// </summary>
 /// <returns></returns>
 public static IEnumerable<Entity.UserRole> GetAllRoles()
 {
     IEnumerable<Entity.UserRole> userRoleList = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         userRoleList = record.UserRoles
             .Select(s => new Entity.UserRole
             {
                 UserRoleID = s.UserRoleID,
                 Name = s.Name,
                 PrivelegeMask = s.PrivilegeMask
             })
             .ToList();
     }
     return userRoleList;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Ger needled role info by role ID.
 /// </summary>
 /// <param name="roleID"></param>
 /// <returns></returns>
 public static UserRole GetRoleInfo(Guid roleID)
 {
     Entity.UserRole rawRoleInfo;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         rawRoleInfo = record.UserRoles
                       .Select(s => new UserRole
         {
             UserRoleID    = s.UserRoleID,
             Name          = s.Name,
             PrivelegeMask = s.PrivilegeMask
         })
                       .FirstOrDefault(f => f.UserRoleID.Equals(roleID));
     }
     return(rawRoleInfo);
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Ger needled role info by role ID.
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public static UserRole GetRoleInfo(Guid roleID)
        {
            Entity.UserRole rawRoleInfo;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                rawRoleInfo = record.UserRoles
                  .Select(s => new UserRole
                  {
                      UserRoleID = s.UserRoleID,
                      Name = s.Name,
                      PrivelegeMask = s.PrivilegeMask
                  })
                  .FirstOrDefault(f => f.UserRoleID.Equals(roleID));

            }
            return rawRoleInfo;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Get list, consists all countries.
        /// </summary>
        /// <returns>All countries.</returns>
        public static IEnumerable<Country> GetAllCountries()
        {
            IEnumerable<Country> recordList = null;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                recordList = record.Countries
                    .OrderBy(o => o.Name)
                    .Select(s => new Country
                    {
                        CountryID = s.CountryID,
                        Name = s.Name
                    })
                    .ToList();
            }

            return recordList;
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Get all user roles on server.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <Entity.UserRole> GetAllRoles()
        {
            IEnumerable <Entity.UserRole> userRoleList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                userRoleList = record.UserRoles
                               .Select(s => new Entity.UserRole
                {
                    UserRoleID    = s.UserRoleID,
                    Name          = s.Name,
                    PrivelegeMask = s.PrivilegeMask
                })
                               .ToList();
            }
            return(userRoleList);
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Get user info.
        /// </summary>
        /// <param name="userID">User id.</param>
        /// <returns>User object.</returns>
        public static User GetUserInfo(Guid userID)
        {
            Entity.User rawUserInfo;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                rawUserInfo = record.Users

                              .Select(s => new User
                {
                    UserID   = s.UserID,
                    Password = s.Password,
                    Email    = s.Email
                })
                              .FirstOrDefault(f => f.UserID.Equals(userID));
                //UserInfo = (rawUserInfo == null) ? null : rawUserInfo;
            }
            return(rawUserInfo);
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Ger all friends of current user.
 /// </summary>
 /// <param name="userID">User's identeficator.</param>
 /// <returns>Return result.</returns>
 public static IEnumerable<Friend> GetUserFriends(Guid userID)
 {
     IEnumerable<Friend> recordList = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         recordList = record.Friends
             .Where(w => w.UserID.Equals(userID) && !w.IsDeleted)
             .Select(s => new Friend
                 {
                     ID = s.ID,
                     UserID = s.UserID,
                     FriendID = s.FriendID,
                     FriendshipDate = s.FriendshipDate,
                     IsDeleted = s.IsDeleted
                 }).ToList();
     }
     return recordList;
 }
 /// <summary>
 /// Get friendlist of current user.
 /// </summary>
 /// <param name="userID">User identifier.</param>
 /// <returns>Friendlist of current user.</returns>
 public static IEnumerable<Entity.FriendInvitation> GetUserFriends(Guid userID)
 {
     IEnumerable<Entity.FriendInvitation> friendList = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         friendList = record.FriendInvitations
             .Where(w => w.ToID.Equals(userID) && !w.IsDeleted)
             .Select(s => new Entity.FriendInvitation
             {
                 InvitationID = s.InvitationID,
                 FromID = s.FromID,
                 ToID = s.ToID,
                 CreateDate = s.CreateDate,
                 Message = s.Message
             }).ToList();
     }
     return friendList;
 }
Ejemplo n.º 35
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<User> GetAllUsers()
        {
            IEnumerable<User> userList = null;
            using (
            SocialNetworkDBEntities record = new SocialNetworkDBEntities()
                )
            {
                userList = record.Users
                    .Select(s => new User
                    {
                        UserID = s.UserID,
                        Email = s.Email,
                        Password = s.Password
                    }).ToList();
            }

            return userList;
        }
Ejemplo n.º 36
0
 /// <summary>
 ///  Get count of all bans.
 /// </summary>
 /// <returns></returns>
 public static Int32 GetAllBansCount()
 {
     IEnumerable<Entity.Ban> ban = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         ban = record.Bans
            .Select(s => new Entity.Ban
            {
                ID = s.ID,
                UserID = s.UserID,
                AdminID = s.AdminID,
                FromDate = s.FromDate,
                ToDate = s.ToDate,
                Reason = s.Reason
            }).ToList();
     }
     return ban.Count();
 }
Ejemplo n.º 37
0
        /// <summary>
        /// Get list, consists all countries.
        /// </summary>
        /// <returns>All countries.</returns>
        public static IEnumerable <Country> GetAllCountries()
        {
            IEnumerable <Country> recordList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                recordList = record.Countries
                             .OrderBy(o => o.Name)
                             .Select(s => new Country
                {
                    CountryID = s.CountryID,
                    Name      = s.Name
                })
                             .ToList();
            }

            return(recordList);
        }
Ejemplo n.º 38
0
        /// <summary>
        ///  Get count of all bans.
        /// </summary>
        /// <returns></returns>
        public static Int32 GetAllBansCount()
        {
            IEnumerable <Entity.Ban> ban = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                ban = record.Bans
                      .Select(s => new Entity.Ban
                {
                    ID       = s.ID,
                    UserID   = s.UserID,
                    AdminID  = s.AdminID,
                    FromDate = s.FromDate,
                    ToDate   = s.ToDate,
                    Reason   = s.Reason
                }).ToList();
            }
            return(ban.Count());
        }
Ejemplo n.º 39
0
        /// <summary>
        /// Get list, consists all cities.
        /// </summary>
        /// <param name="countryID">Country identifier.</param>
        /// <returns>All cities.</returns>
        public static IEnumerable<City> GetAllCountryCities(Guid countryID)
        {
            IEnumerable<City> recordList = null;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                recordList = record.Cities
                    .Where(w => w.CountryID == countryID)
                    .OrderBy(o => o.Name)
                    .Select(s => new City
                    {
                        CityID = s.CityID,
                        CountryID = s.CountryID,
                        Name = s.Name
                    })
                    .ToList();
            }

            return recordList;
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Get friendlist of current user.
        /// </summary>
        /// <param name="userID">User identifier.</param>
        /// <returns>Friendlist of current user.</returns>
        public static IEnumerable <Entity.FriendInvitation> GetUserFriends(Guid userID)
        {
            IEnumerable <Entity.FriendInvitation> friendList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                friendList = record.FriendInvitations
                             .Where(w => w.ToID.Equals(userID) && !w.IsDeleted)
                             .Select(s => new Entity.FriendInvitation
                {
                    InvitationID = s.InvitationID,
                    FromID       = s.FromID,
                    ToID         = s.ToID,
                    CreateDate   = s.CreateDate,
                    Message      = s.Message
                }).ToList();
            }
            return(friendList);
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Ger all friends of current user.
        /// </summary>
        /// <param name="userID">User's identeficator.</param>
        /// <returns>Return result.</returns>
        public static IEnumerable <Friend> GetUserFriends(Guid userID)
        {
            IEnumerable <Friend> recordList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                recordList = record.Friends
                             .Where(w => w.UserID.Equals(userID) && !w.IsDeleted)
                             .Select(s => new Friend
                {
                    ID             = s.ID,
                    UserID         = s.UserID,
                    FriendID       = s.FriendID,
                    FriendshipDate = s.FriendshipDate,
                    IsDeleted      = s.IsDeleted
                }).ToList();
            }
            return(recordList);
        }
Ejemplo n.º 42
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <User> GetAllUsers()
        {
            IEnumerable <User> userList = null;

            using (
                SocialNetworkDBEntities record = new SocialNetworkDBEntities()
                )
            {
                userList = record.Users
                           .Select(s => new User
                {
                    UserID   = s.UserID,
                    Email    = s.Email,
                    Password = s.Password
                }).ToList();
            }

            return(userList);
        }
Ejemplo n.º 43
0
 /// <summary>
 /// Get information about current ban.
 /// </summary>
 /// <param name="banID">Ban identifier.</param>
 /// <returns>Ban object.</returns>
 public static Ban GetBanInfo(Guid banID)
 {
     Entity.Ban rawBanInfo;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         rawBanInfo = record.Bans
                      .Select(s => new Ban
         {
             ID       = s.ID,
             UserID   = s.UserID,
             AdminID  = s.AdminID,
             FromDate = s.FromDate,
             ToDate   = s.ToDate,
             Reason   = s.Reason
         })
                      .FirstOrDefault(f => f.ID.Equals(banID));
     }
     return(rawBanInfo);
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Get user's friends with needled params.
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="startRow"></param>
 /// <param name="rowCount"></param>
 /// <returns></returns>
 public static IEnumerable<Friend> GetUserFriendsWithParams(Guid userID, Int32 startRow, Int32 rowCount, bool online)
 {
     IEnumerable<Friend> recordList = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         recordList = record.Friends
             .Where(w => w.UserID.Equals(userID) && !w.IsDeleted)
             .Select(s => new Friend
             {
                 ID = s.ID,
                 UserID = s.UserID,
                 FriendID = s.FriendID,
                 FriendshipDate = s.FriendshipDate,
                 IsDeleted = s.IsDeleted
             }).OrderBy(o => o.FriendshipDate).Skip(startRow).Take(rowCount).ToList();
     }
     if (!online)
         return recordList;
     else return recordList.Where(w => StatusRepository.GetStatusID(w.FriendID) != 0);
 }
Ejemplo n.º 45
0
        /// <summary>
        /// Get list, consists all cities.
        /// </summary>
        /// <param name="countryID">Country identifier.</param>
        /// <returns>All cities.</returns>
        public static IEnumerable <City> GetAllCountryCities(Guid countryID)
        {
            IEnumerable <City> recordList = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                recordList = record.Cities
                             .Where(w => w.CountryID == countryID)
                             .OrderBy(o => o.Name)
                             .Select(s => new City
                {
                    CityID    = s.CityID,
                    CountryID = s.CountryID,
                    Name      = s.Name
                })
                             .ToList();
            }

            return(recordList);
        }
Ejemplo n.º 46
0
        /// <summary>
        /// Get active bans from current user.
        /// </summary>
        /// <param name="userID">User identifier.</param>
        /// <returns>List of user active bans.</returns>
        public static IEnumerable <Ban> GetUserBans(Guid userID)
        {
            IEnumerable <Ban> ban = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                ban = record.Bans
                      .Where(w => w.UserID.Equals(userID) && !w.IsDeleted)
                      .Select(s => new Ban
                {
                    ID       = s.ID,
                    UserID   = s.UserID,
                    AdminID  = s.AdminID,
                    FromDate = s.FromDate,
                    ToDate   = s.ToDate,
                    Reason   = s.Reason
                })
                      .ToList();
            }
            return(ban);
        }
 /// <summary>
 /// Select list of current user wallboards items.
 /// </summary>
 /// <param name="userID">User identifier.</param>
 /// <returns>List of wallboards items.</returns>
 public static IEnumerable<WallBoardItem> GetUserWallboardItems(Guid userID)
 {
     IEnumerable<WallBoardItem> recordList = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         recordList = record.WallBoardItems
             .Where(w => w.ToID == userID && !w.IsDeleted)
             .OrderByDescending(o => o.SendDate)
             .Select(s => new WallBoardItem
             {
                 ID = s.ID,
                 ContentTypeID = s.ContentTypeID,
                 FromID = s.FromID,
                 ToID = s.ToID,
                 SendDate = s.SendDate,
                 Message = s.Message,
                 IsDeleted = s.IsDeleted,
                 NullLink = s.NullLink
             })
             .ToList();
     }
     return recordList;
 }
        /// <summary>
        /// Select list of wallboards items.
        /// </summary>
        /// <returns>List of wallboards items.</returns>
        public static IEnumerable <WallBoardItem> SelectAllItems()
        {
            IEnumerable <WallBoardItem> list = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                list = record.WallBoardItems
                       .OrderByDescending(o => o.SendDate)
                       .Select(s => new WallBoardItem
                {
                    ID            = s.ID,
                    ContentTypeID = s.ContentTypeID,
                    FromID        = s.FromID,
                    ToID          = s.ToID,
                    SendDate      = s.SendDate,
                    Message       = s.Message,
                    IsDeleted     = s.IsDeleted,
                    NullLink      = s.NullLink
                })
                       .ToList();
            }
            return(list);
        }
Ejemplo n.º 49
0
 /// <summary>
 /// Get all bans.
 /// </summary>
 /// <param name="startRowIndex">Select started row.</param>
 /// <param name="maximumRows">Select row count.</param>
 /// <returns></returns>
 public static IEnumerable<Entity.Ban> GetAllBans(Int32 startRowIndex, Int32 maximumRows)
 {
     IEnumerable<Entity.Ban> ban = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         ban = record.Bans
             .Where(w => !w.IsDeleted)
             .Select(s => new Entity.Ban
             {
                 ID = s.ID,
                 UserID = s.UserID,
                 AdminID = s.AdminID,
                 FromDate = s.FromDate,
                 ToDate = s.ToDate,
                 Reason = s.Reason
             })
             .OrderBy(o => o.FromDate)
             .Skip(startRowIndex)
             .Take(maximumRows)
             .ToList();
     }
     return ban;
 }
Ejemplo n.º 50
0
        /// <summary>
        /// Get all bans.
        /// </summary>
        /// <param name="startRowIndex">Select started row.</param>
        /// <param name="maximumRows">Select row count.</param>
        /// <returns></returns>
        public static IEnumerable <Entity.Ban> GetAllBans(Int32 startRowIndex, Int32 maximumRows)
        {
            IEnumerable <Entity.Ban> ban = null;

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                ban = record.Bans
                      .Where(w => !w.IsDeleted)
                      .Select(s => new Entity.Ban
                {
                    ID       = s.ID,
                    UserID   = s.UserID,
                    AdminID  = s.AdminID,
                    FromDate = s.FromDate,
                    ToDate   = s.ToDate,
                    Reason   = s.Reason
                })
                      .OrderBy(o => o.FromDate)
                      .Skip(startRowIndex)
                      .Take(maximumRows)
                      .ToList();
            }
            return(ban);
        }
Ejemplo n.º 51
0
 /// <summary>
 /// Get active bans from current user.
 /// </summary>
 /// <param name="userID">User identifier.</param>
 /// <returns>List of user active bans.</returns>
 public static IEnumerable<Ban> GetUserBans(Guid userID)
 {
     IEnumerable<Ban> ban = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         ban = record.Bans
             .Where(w => w.UserID.Equals(userID) && !w.IsDeleted)
             .Select(s => new Ban
             {
                 ID = s.ID,
                 UserID = s.UserID,
                 AdminID = s.AdminID,
                 FromDate = s.FromDate,
                 ToDate = s.ToDate,
                 Reason = s.Reason
             })
             .ToList();
     }
     return ban;
 }
Ejemplo n.º 52
0
        /// <summary>
        /// Get name of user city.
        /// </summary>
        /// <param name="cityID">City identificator.</param>
        /// <returns>City name.</returns>
        public static String GetCityName(Guid cityID)
        {
            String cityName = String.Empty;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                var rawCity = record.Cities.FirstOrDefault(f => f.CityID == cityID);
                cityName = rawCity == null ? _defaultCityName : rawCity.Name;
            }

            return cityName;
        }
Ejemplo n.º 53
0
 public static IEnumerable<SocialNetwork.DataAccess.UserRole> GetUserRoles(Guid userID)
 {
     IEnumerable<SocialNetwork.DataAccess.UserRole> userRoleList = null;
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         userRoleList = record.spRoleGet(userID).ToList();
     }
     return userRoleList;
 }
Ejemplo n.º 54
0
        /// <summary>
        /// Get user info.
        /// </summary>
        /// <param name="userID">User id.</param>
        /// <returns>User object.</returns>
        public static User GetUserInfo(Guid userID)
        {
            Entity.User rawUserInfo;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                rawUserInfo = record.Users

                  .Select(s => new User
                  {
                      UserID = s.UserID,
                      Password = s.Password,
                      Email = s.Email
                  })
                  .FirstOrDefault(f => f.UserID.Equals(userID));
                //UserInfo = (rawUserInfo == null) ? null : rawUserInfo;
            }
            return rawUserInfo;
        }
Ejemplo n.º 55
0
 /// <summary>
 /// Modify ban's object.
 /// </summary>
 /// <param name="id">Ban's identeficator.</param>
 /// <param name="updateByUser">Updated by user flag.</param>
 /// <param name="userID">User's identeficator.</param>
 /// <param name="adminID">Admin's identeficator.</param>
 /// <param name="reason">Ban's reason.</param>
 /// <param name="fromDate">Ban's from date.</param>
 /// <param name="toDate">Ban's to date.</param>
 /// <param name="isDeleted">Logical deleting.</param>
 public static void ModifyBan(
    Guid? id,
    Boolean? updateByUser,
    Guid? userID,
    Guid? adminID,
    String reason,
    DateTime? fromDate,
    DateTime? toDate,
    Boolean? isDeleted)
 {
     ObjectParameter pkID = (id != null) ? new ObjectParameter("pkID", id)
         : new ObjectParameter("pkID", typeof(Guid));
     using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
     {
         record.spBan(
             pkID,
             updateByUser,
             userID,
             adminID,
             reason,
             fromDate,
             toDate,
             isDeleted
             );
     }
 }
Ejemplo n.º 56
0
        /// <summary>
        /// Get information about current ban.
        /// </summary>
        /// <param name="banID">Ban identifier.</param>
        /// <returns>Ban object.</returns>
        public static Ban GetBanInfo(Guid banID)
        {
            Entity.Ban rawBanInfo;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                rawBanInfo = record.Bans
                  .Select(s => new Ban
                  {
                      ID = s.ID,
                      UserID = s.UserID,
                      AdminID = s.AdminID,
                      FromDate = s.FromDate,
                      ToDate = s.ToDate,
                      Reason = s.Reason
                  })
                  .FirstOrDefault(f => f.ID.Equals(banID));

            }
            return rawBanInfo;
        }
Ejemplo n.º 57
0
        /// <summary>
        /// Modify PersonalInfo.
        /// </summary>
        /// <param name="id">Primary key identity.</param>
        /// <param name="updateByUser">Update type flag.</param>
        /// <param name="updateImagePath">Update image flag.</param>
        /// <param name="userID">Foreign key identity.</param>
        /// <param name="nickName">Nick name.</param>
        /// <param name="firstName">First name.</param>
        /// <param name="lastName">Last name.</param>
        /// <param name="middleName">Middle name.</param>
        /// <param name="sex">User sex.</param>
        /// <param name="phone">User phone.</param>
        /// <param name="birthday">Birthday date.</param>
        /// <param name="imagePath">Avatar image path.</param>
        /// <param name="description">Personal description.</param>
        public static void ModifyPersonalInfo(
            Guid? id,
            Boolean updateByUser,
            Boolean updateImagePath,
            Guid userID,
            String nickName,
            String firstName,
            String lastName,
            String middleName,
            Sex? sex,
            String phone,
            DateTime? birthday,
            String imagePath,
            String description)
        {
            ObjectParameter pkID = (id != null) ? new ObjectParameter("pkID", id)
                : new ObjectParameter("pkID", typeof(Guid));

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                record.spPersonalInfo(
                    pkID,
                    updateByUser,
                    updateImagePath,
                    userID,
                    nickName,
                    firstName,
                    lastName,
                    middleName,
                    (Byte?)sex,
                    phone,
                    birthday,
                    imagePath,
                    description);
            }
        }
Ejemplo n.º 58
0
        /// <summary>
        /// Send message to another user.
        /// </summary>
        /// <param name="senderID">Sender identifier.</param>
        /// <param name="receiverID">Receiver identifier.</param>
        /// <param name="header">Message title.</param>
        /// <param name="text">Message text.</param>
        public static void SendPrivateMessage(Guid senderID, Guid receiverID, String header, String text)
        {
            ObjectParameter pkMessageID = new ObjectParameter("pkMessageID", typeof(Guid));

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                record.spMessage(pkMessageID, senderID, receiverID, header, text, true, false, false);
            }
        }
Ejemplo n.º 59
0
        /// <summary>
        /// Set status 'read' to current message.
        /// </summary>
        /// <param name="messageID">Message identifier.</param>
        public static void SetReadStatus(Guid messageID)
        {
            ObjectParameter pkMessageID = new ObjectParameter("pkMessageID", messageID);

            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                record.spMessage(pkMessageID, null, null, null, null, true, null, null);
            }
        }
Ejemplo n.º 60
0
        /// <summary>
        /// Get all messages of current user.
        /// </summary>
        /// <param name="userID">Sender user idetifier.</param>
        /// <param name="type">Type of message.</param>
        /// <param name="selectType">Type of message selecting.</param>
        /// <returns>List of user messages.</returns>
        public static IEnumerable<Message> GetUserMessages(
            Guid userID, MessageType type, MessageSelectType selectType)
        {
            IEnumerable<Message> recordList = null;
            using (SocialNetworkDBEntities record = new SocialNetworkDBEntities())
            {
                if (type.Equals(MessageType.Posted))
                {
                    switch (selectType)
                    {
                        case MessageSelectType.All:
                            {
                                recordList = record.Messages
                                    .Where(w => w.FromID == userID && !w.IsDeletedBySender)
                                    .OrderByDescending(o => o.SendDate)
                                    .Select(s => new Message
                                    {
                                        MessageID = s.MessageID,
                                        FromID = s.FromID,
                                        ToID = s.ToID,
                                        SendDate = s.SendDate,
                                        Header = s.Header,
                                        Text = s.Text,
                                        Status = s.Status,
                                        IsDeletedBySender = s.IsDeletedBySender,
                                        IsDeletedByReceiver = s.IsDeletedByReceiver
                                    })
                                    .ToList();
                            }
                            break;
                        case MessageSelectType.OnlyNew:
                            {
                            }
                            break;
                        case MessageSelectType.OnlyOld:
                            {
                            }
                            break;
                    }
                }
                else
                {
                    switch (selectType)
                    {
                        case MessageSelectType.All:
                            {
                                recordList = record.Messages
                                    .Where(w => w.ToID == userID && !w.IsDeletedByReceiver)
                                    .OrderByDescending(o => o.SendDate)
                                    .Select(s => new Message
                                    {
                                        MessageID = s.MessageID,
                                        FromID = s.FromID,
                                        ToID = s.ToID,
                                        SendDate = s.SendDate,
                                        Header = s.Header,
                                        Text = s.Text,
                                        Status = s.Status,
                                        IsDeletedBySender = s.IsDeletedBySender,
                                        IsDeletedByReceiver = s.IsDeletedByReceiver
                                    })
                                    .ToList();
                            }
                            break;
                        case MessageSelectType.OnlyNew:
                            {
                            }
                            break;
                        case MessageSelectType.OnlyOld:
                            {
                            }
                            break;
                    }
                }
            }

            return recordList;
        }