Exemplo n.º 1
0
 // gets the message history from a room, conversation or user
 public dynamic getMessageHistory(int roomId, long conversationId, long otherUserId)
 {
     try
     {
         return(_chat.GetMessageHistoryByUserID(CurrentUser.UserID, otherUserId, roomId, conversationId));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error fetching the message history", ex);
         return(null);
     }
 }
Exemplo n.º 2
0
 //// gets the given user info
 public dynamic getUserInfo(long userId)
 {
     try
     {
         return(_chat.GetUserInfoByUserID(userId));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error fetching the user information", ex);
         return(null);
     }
 }
 /// <summary>
 /// Get users friend requests
 /// </summary>
 /// <param name="PageNumber"></param>
 public async Task <IHttpActionResult> GetFriendRequests(int PageNumber, int PageSize)
 {
     try
     {
         return(Ok(_user.GetFriendRequests(CurrentUser.UserID, PageNumber, PageSize)));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error getting  list  of user's friend request", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 4
0
 // gets the user list in a room or conversation
 public dynamic getUserList(int roomId, long conversationId = 1)
 {
     try
     {
         return(_chat.GetFollowerListByUserID(CurrentUser.UserID));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error fetching the list of followers", ex);
         return(null);
     }
 }
 /// <summary>
 /// Get users notfications
 /// </summary>
 /// <param name="PageNumber"></param>
 public async Task <IHttpActionResult> GetNotifications(int PageNumber, int PageSize)
 {
     try
     {
         return(Ok(_user.GetNotifications(CurrentUser.UserID, PageNumber, PageSize)));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error getting users notifications", ex);
         return(BadRequest(ex.Message));
     }
 }
 /// <summary>
 /// Get search's pages
 /// </summary>
 /// <param name="PageNumber"></param>
 public async Task <IHttpActionResult> GetSearchNewPages(String Key, int PageNumber, int PageSize)
 {
     try
     {
         return(Ok(_user.GetSearchNewPages(CurrentUser.UserID, Key, PageNumber, PageSize)));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error getting  list  of search's pages", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// get list of posts of a page
 /// </summary>
 /// <param name="PageNumber"></param>
 /// <param name="PageSize"></param>
 /// <param name="PageID"></param>
 public async Task <IHttpActionResult> GetPosts(int PageNumber, int PageSize, int PageType, long PageID, bool?IsHome)
 {
     try
     {
         var _model = _post.GetPosts(!IsHome.Value ? CurrentUser.UserID : -1, PageType, PageID, PageNumber, PageSize);
         return(Ok(_model));
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error getting page posts list", ex);
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// user list changed
 /// </summary>
 /// <param name="roomId"></param>
 /// <param name="conversationId"></param>
 protected void userListChanged(int roomId, long conversationId)
 {
     try
     {
         Clients.Others.userListChanged(new
         {
             UserList       = _hub.GetFollowerListByUserID(CurrentUser.UserID),
             RoomId         = roomId,
             ConversationId = conversationId
         });
     }
     catch (Exception ex)
     {
         ExceptionService.LogError("Error getting followers list", ex);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// hide post to page
 /// </summary>
 /// <param name="post"></param>
 /// <returns></returns>
 public async Task <IHttpActionResult> HidePost(PostModel post)
 {
     if (ModelState.IsValid)
     {
         try
         {
             return(Ok(_post.HidePost(post)));
         }
         catch (Exception ex)
         {
             ExceptionService.LogError("Error hiding post to page", ex);
             return(BadRequest(ex.Message));
         }
     }
     else
     {
         return(BadRequest(ModelState.JsonValidation()));
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Hub overriden methood while disconnecting
        /// </summary>
        /// <returns></returns>
        public System.Threading.Tasks.Task OnDisconnected()
        {
            try
            {
                CurrentUser.StatusID = 2;
                _hub.UpdateUserStatus(CurrentUser.UserID, Context.ConnectionId, Enums.BroadCastType.Web, Enums.UserStatus.OFL);
                IList <string> connectionIDs = new BusinessLogic.UserAccess()
                                               .GetFollowerListByConnectID(CurrentUser.UserID, Enums.PageType.Profile, Enums.FriendshipStatus.FA)
                                               .Where(x => x.ConnectedBy == (byte)Enums.BroadCastType.Web).Select(x => x.ConnectionID).ToList();

                Clients.Clients(connectionIDs).updateUserList(GetMyChatInfo(1));
            }
            catch (Exception ex)
            {
                ExceptionService.LogError("Error updating user status", ex);
            }

            return(base.OnDisconnected(false));
        }
Exemplo n.º 11
0
 /// <summary>
 /// get left pane detail of users home page
 /// </summary>
 /// <param name="UserID"></param>
 /// <returns></returns>
 public async Task <IHttpActionResult> GetLeftHomeInfo(long UserID)
 {
     if (ModelState.IsValid)
     {
         try
         {
             return(Ok(_page.GetLeftHomeInfo(UserID)));
         }
         catch (Exception ex)
         {
             ExceptionService.LogError("Error fetching detail of home left pane", ex);
             return(BadRequest(ex.Message));
         }
     }
     else
     {
         return(BadRequest(ModelState.JsonValidation()));
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Load header at first page load
        /// </summary>
        public void GetHeader()
        {
            try
            {
                var ret = new
                {
                    Notifications = _hub.GetNotifications(CurrentUser.UserID, 1, 10),

                    Messages = _hub.GetMessages(CurrentUser.UserID, 1, 10),

                    FriendRequests = _hub.GetFriendRequests(CurrentUser.UserID, 1, 10),

                    UserInfo = GetMyInfo()
                };
                Clients.Caller.loadHeader(ret);
            }
            catch (Exception ex)
            {
                ExceptionService.LogError("Error getting heder for users page", ex);
            }
        }
Exemplo n.º 13
0
        // sends a message to a room, conversation or user
        public void sendMessage(ChatMessageModel message)//int roomId, long conversationId, long otherUserId, string messageText, string clientGuid)
        {
            try
            {
                message.FromID         = CurrentUser.UserID;
                message.CreatedOn      = DateTime.Now;
                message.PostedByName   = CurrentUser.FullName;
                message.PostedByAvatar = CurrentUser.ProfilePicture;
                message.FromName       = CurrentUser.UserName;

                BroadcastChatMessage model = _hub.SendChatMessage(message);

                IList <string> connectionIDs = new BusinessLogic.UserAccess().GetFollowerList(model.ChatMessage.FromID, model.ChatMessage.ToID, model.ChatMessage.PageType, Enums.FriendshipStatus.FA)
                                               .Where(x => x.ConnectedBy == (byte)Enums.BroadCastType.Web).Select(x => x.ConnectionID).ToList();

                Clients.Clients(connectionIDs).sendMessage(model.ChatMessage);
            }
            catch (Exception ex)
            {
                ExceptionService.LogError("Error while sending message.", ex);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="PageNumber"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageType"></param>
        /// <param name="PageID"></param>
        /// <returns></returns>
        public async Task <IHttpActionResult> GetHeader()
        {
            try
            {
                var _model = new
                {
                    Notifications = _user.GetNotifications(CurrentUser.UserID, 1, 10),

                    Messages = _user.GetMessages(CurrentUser.UserID, 1, 10),

                    FriendRequests = _user.GetFriendRequests(CurrentUser.UserID, 1, 10),

                    UserInfo = GetMyInfo()
                };
                return(Ok(_model));
            }
            catch (Exception ex)
            {
                ExceptionService.LogError("Error getting heder for users page", ex);
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 15
0
        public async Task <IHttpActionResult> RemoveFriend(FriendRequestModel FriendRequest)
        {
            if (FriendRequest.PageID == CurrentUser.UserID)
            {
                long _temp = FriendRequest.PageID;
                FriendRequest.PageID = CurrentUser.UserID;
                FriendRequest.UserID = _temp;
            }
            else
            {
                FriendRequest.UserID = CurrentUser.UserID;
            }
            FriendRequest.CreatedOn = DateTime.Now;
            ModelState.Remove("FriendRequest.PageID");
            ModelState.Remove("FriendRequest.CreatedOn");
            FriendRequest.PostedByName       = CurrentUser.FullName;
            FriendRequest.PostedByAvatar     = CurrentUser.ProfilePicture;
            FriendRequest.PageRelationStatus = Enums.FriendshipStatus.FA;
            if (ModelState.IsValid)
            {
                try
                {
                    BroadcastFriendRequest model = _page.RejectUserFriendRequest(FriendRequest);
                    await _broadcaster.CancelFriendRequest(model, FriendRequest.broadCastType);

                    return(Ok(model.FriendRequest));
                }
                catch (Exception ex)
                {
                    ExceptionService.LogError("Error remove friend to page", ex);
                    return(BadRequest(ex.Message));
                }
            }
            else
            {
                return(BadRequest(ModelState.JsonValidation()));
            }
        }
Exemplo n.º 16
0
 /// <summary>
 ///  Get page detail
 /// </summary>
 /// <param name="UserID"></param>
 /// <param name="PageID"></param>
 /// <param name="PageType"></param>
 /// <returns></returns>
 public async Task <IHttpActionResult> GetPageInfo(long PageID, Enums.PageType PageType)
 {
     if (!Enum.IsDefined(typeof(Enums.PageType), PageType))
     {
         ModelState.AddModelError("PageType", "PageType of page is not valid.");
     }
     if (ModelState.IsValid)
     {
         try
         {
             return(Ok(_page.GetPageInfo(CurrentUser.UserID, PageID, PageType)));
         }
         catch (Exception ex)
         {
             ExceptionService.LogError("Error fetching detail of page", ex);
             return(BadRequest(ex.Message));
         }
     }
     else
     {
         return(BadRequest(ModelState.JsonValidation()));
     }
 }
Exemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FriendRequest"></param>
        /// <returns></returns>
        public async Task <IHttpActionResult> SavePageDetail(AboutPageModel AboutPage)
        {
            if (AboutPage.Id != CurrentUser.UserID)
            {
                ModelState.AddModelError("Unauthorized", "You are not authorized to do that");
            }

            AboutPage.Id = CurrentUser.UserID;

            AboutPage.LastUpdatedOn = DateTime.Now;
            ModelState.Remove("FriendRequest.UserID");
            ModelState.Remove("FriendRequest.CreatedOn");
            if (ModelState.IsValid)
            {
                try
                {
                    AboutPageModel _result = _page.SavePageDetail(AboutPage);
                    if (_result == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        return(Ok(_result));
                    }
                }
                catch (Exception ex)
                {
                    ExceptionService.LogError("Error saving page detail", ex);
                    return(BadRequest(ex.Message));
                }
            }
            else
            {
                return(BadRequest(ModelState.JsonValidation()));
            }
        }
Exemplo n.º 18
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!ValidateCaptcha(Request["g-recaptcha-response"]))
                {
                    ModelState.AddModelError("", "Invalid captcha attempt.");
                    return(View(model));
                }
                var user = new ApplicationUser
                {
                    UserName       = model.UserName,
                    Email          = model.EmailID,
                    FullName       = model.Name,
                    BirthDate      = new DateTime(model.DOB.Year, model.DOB.Month, model.DOB.Day),
                    CreatedOn      = DateTime.Now,
                    Gender         = model.Gender,
                    Active         = true,
                    LastStatusOn   = DateTime.Now,
                    StatusID       = 1,
                    ProfilePicture = "/Profiles/Common/ProfilePic/user.png",
                    CoverPicture   = "/Profiles/Common/ProfileCoverPic/Hydrangeas.jpg"
                };

                try
                {
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Album\"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Album\Icon"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Images\"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Images\Icon"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Audio\"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Audio\Icon"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Video\"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Video\Icon"));
                        System.IO.Directory.CreateDirectory(Server.MapPath(@"~\Profiles\" + user.Id + @"\Temp\"));
                        // Send an email with this link


                        string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                        ExceptionService.LogDebug("After generating token");

                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        ExceptionService.LogDebug("After email sent");

                        return(RedirectToAction("RequireEmailConfirmation", "Account"));
                    }
                    AddErrors(result);
                }
                catch (Exception ex)
                {
                    ExceptionService.LogError("Error in registration", ex);
                }
                //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                //return RedirectToAction("Index", "Home");
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }