Ejemplo n.º 1
0
        /// <summary>
        /// Delete Combo User from db
        /// </summary>
        /// <param name="ID">Combo User ID</param>
        /// <returns>ComboResponse object with Delete Result</returns>        
        public HttpResponseMessage DeleteUser(int ID)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUser user = new ComboUser();
            if (!user.LoadByPrimaryKey(ID))
            {
                _response.ErrorCode = 11;
                _response.ErrorMsg = "User doesn't exist";
                _response.bool_result = false;

            }
            else
            {
                user.MarkAsDeleted();
                user.Save();
            }

            _response.Entity = null;
            var response = Request.CreateResponse<Models.ComboResponse>(_response);
            return response;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add Combo user to db
        /// </summary>
        /// <param name="user">Combo user object to be added</param>
        /// <returns>ComboResponse object with Added User object</returns>
        public HttpResponseMessage AddUser(Models.ComboUser user)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            BLL.ComboUser newUser = new ComboUser();
            BLL.ComboUser _user = new ComboUser();
            if (_user.GetUserByUserName(user.UserName))
            {
                _response.ErrorCode = 12;
                _response.ErrorMsg = "Username exists before";
                _response.bool_result = false;
                var res = Request.CreateResponse<Models.ComboResponse>(_response);
                return res;
            }
            newUser.AddNew();
            newUser.UserName = user.UserName;
            if (!string.IsNullOrEmpty(user.DisplayName))
                newUser.DisplayName = user.DisplayName;
            newUser.Password = user.Password;
            newUser.Email = user.Email;
            if (!string.IsNullOrEmpty(user.Bio))
                newUser.Bio = user.Bio;
            if (user.ProfileImgID != 0)
                newUser.ProfileImgID = user.ProfileImgID;
            if (user.CoverImgID != 0)
                newUser.CoverImgID = user.CoverImgID;
            if (user.GenderID !=0 )
                newUser.GenderID = user.GenderID;
            newUser.IsActivated = user.IsActivated;
            if (user.ExternalIDType != 0)
            {
                newUser.ExternalIDType = user.ExternalIDType;
                newUser.ExternalID = user.ExternalID;
            }
            if (!string.IsNullOrEmpty(user.DeviceID))
                newUser.DeviceID = user.DeviceID;
            newUser.Save();

            user.ComboUserID = newUser.ComboUserID;
            _response.Entity = user;

            var response = Request.CreateResponse<Models.ComboResponse>(_response);
            return response;
        }
Ejemplo n.º 3
0
        public void DeleteCommnet(int id)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboComment comment = new ComboComment();
            comment.LoadByPrimaryKey(id);
            comment.IsDeleted = true;
            comment.Save();
            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 4
0
        public void AddUser(Models.ComboUser user)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            BLL.ComboUser newUser = new ComboUser();
            BLL.ComboUser _user = new ComboUser();
            if (_user.GetUserByUserName(user.UserName) || _user.GetUserByUserName(user.Email))
            {
                _response.ErrorCode = 12;
                _response.ErrorMsg = "Username or Email exists before";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            //if (string.IsNullOrEmpty(user.SecurityQuestion))
            //{
            //    _response.ErrorCode = 14;
            //    _response.ErrorMsg = "No secuity question found";
            //    _response.bool_result = false;
            //    SetContentResult(_response);
            //    return;
            //}

            //if (string.IsNullOrEmpty(user.SecurityAnswer))
            //{
            //    _response.ErrorCode = 15;
            //    _response.ErrorMsg = "No security answer found";
            //    _response.bool_result = false;
            //    SetContentResult(_response);
            //    return;
            //}
            if (string.IsNullOrEmpty(user.SecurityWord))
            {
                _response.ErrorCode = 15;
                _response.ErrorMsg = "No security word found";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }
            newUser.AddNew();
            newUser.UserName = user.UserName;
            if (!string.IsNullOrEmpty(user.DisplayName))
                newUser.DisplayName = user.DisplayName;
            newUser.Password = user.Password;
            newUser.Email = user.Email;
            //newUser.SecurityQuestion = user.SecurityQuestion;
            //newUser.SecurityAnswer = user.SecurityAnswer;
            newUser.SecurityWord = user.SecurityWord;
            if (!string.IsNullOrEmpty(user.Bio))
                newUser.Bio = user.Bio;
            if (user.ProfileImgID != 0)
                newUser.ProfileImgID = user.ProfileImgID;
            if (user.CoverImgID != 0)
                newUser.CoverImgID = user.CoverImgID;
            if (user.GenderID != 0)
                newUser.GenderID = user.GenderID;
            newUser.IsActivated = user.IsActivated;
            if (user.ExternalIDType != 0)
            {
                newUser.ExternalIDType = user.ExternalIDType;
                newUser.ExternalID = user.ExternalID;
            }
            if (!string.IsNullOrEmpty(user.DeviceID))
                newUser.DeviceID = user.DeviceID;

            // set rank by default
            newUser.UserRankID = 1;

            if (user.BirthDate != DateTime.MinValue)
                newUser.BirthDate = user.BirthDate;
            if (!string.IsNullOrEmpty(user.Country))
                newUser.Country  = user.Country;
            if (!string.IsNullOrEmpty(user.Phone))
                newUser.Phone = user.Phone;
            if (!string.IsNullOrEmpty(user.Website))
                newUser.Website = user.Website;
            if (user.CountryID != 0)
                newUser.CountryID = user.CountryID;
            if (!string.IsNullOrEmpty(user.Location))
                newUser.Location = user.Location;

            try
            {
                newUser.IsPrivateAccount = user.IsPrivateAccount;
            }
            catch (Exception ex)
            {

            }

            newUser.Save();

            user.ComboUserID = newUser.ComboUserID;
            _response.Entity = new Models.ComboUser[]{ user};

            try
            {
                MailMessage msg = new MailMessage();
                string body = Combo.Properties.Resources.registrationBody;
                string mail = Combo.Properties.Resources.mail;

                string mailto = user.Email;
                msg.To.Add(mailto);
                msg.From = new MailAddress(mail);
                msg.Subject = Combo.Properties.Resources.registrationSubject;
                msg.IsBodyHtml = true;
                msg.BodyEncoding = System.Text.Encoding.UTF8;

                msg.Body = string.Format(body, user.UserName);

                SmtpClient client = new SmtpClient(Combo.Properties.Resources.mailserver, Convert.ToInt32(Combo.Properties.Resources.port));

                client.UseDefaultCredentials = false;
                //client.EnableSsl = true;
                client.Credentials = new System.Net.NetworkCredential(mail, Combo.Properties.Resources.mailpass);
                client.Send(msg);
            }
            catch (Exception ex)
            {
                //_response.ErrorCode = 9999;
                //_response.ErrorMsg = "An Error Occured.Please try again.<br />" + ex.Message;
                //_response.bool_result = false;
            }

            SetContentResult(_response);
            return;
        }
Ejemplo n.º 5
0
        public void UpdatePost(Models.ComboPost post)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            BLL.ComboPost newPost = new ComboPost();
            newPost.LoadByPrimaryKey(post.ComboPostID);
            newPost.PostText = post.PostText.Replace("\n", " "); ;
            newPost.PostDate = DateTime.UtcNow;
            newPost.Save();

            JavaScriptSerializer js = new JavaScriptSerializer();
            Models.Attachment[] att = js.Deserialize<Models.Attachment[]>(js.Serialize(post.Attachments));

            ComboPostAttachment attachment = new ComboPostAttachment();
            foreach (Models.Attachment item in att)
            {
                try
                {
                    attachment.AddNew();
                    attachment.AttachmentID = item.AttachmentID;
                    attachment.ComboPostID = newPost.ComboPostID;
                    attachment.Save();
                }
                catch (Exception ex)
                {

                }

            }

            post.PostDate = newPost.PostDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            _response.Entity = new Models.ComboPost[] { post };

            SetContentResult(_response);
            return;
        }
Ejemplo n.º 6
0
        public void ToggleLikePostByID(int id,int userid)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboPostAttachment att = new ComboPostAttachment();
            att.GetPostAttachmentsByPostID(id);

            ComboPostLike likes = new ComboPostLike();
            if (!likes.LoadByPrimaryKey(userid, id))
            {
                likes.AddNew();
                likes.ComboPostID = id;
                likes.ComboUserID = userid;
                likes.Save();

                // save notification and push it to device
                ComboPost post = new ComboPost();
                post.LoadByPrimaryKey(id);
                ComboUser creator = new ComboUser();
                ComboUser liker = new ComboUser();
                creator.LoadByPrimaryKey(post.ComboUserID);
                liker.GetUserByUserId(userid);
                if (creator.ComboUserID != liker.ComboUserID)
                {
                    List<Models.ComboPostLike> alike = likes.DefaultView.Table.AsEnumerable().Select(row =>
                        {
                            return new Models.ComboPostLike
                            {
                                ComboPostID = Convert.ToInt32(row["ComboPostID"]),
                                ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                                UserName = liker.UserName,
                                DisplayName = liker.DisplayName,
                                PostText = post.PostText,
                                ProfilePic = liker.GetColumn("ProfilePic").ToString(),
                                Attachments = att.DefaultView.Table.AsEnumerable().Select(r =>
                                {
                                    return new Models.Attachment
                                    {
                                        AttachmentID = Convert.ToInt32(r["AttachmentID"]),
                                        Path = r["Path"].ToString(),
                                        AttachmentTypeID = Convert.ToInt32(r["AttachmentTypeID"]),
                                        ThumbsPath = r["ThumbsPath"].ToString()
                                    };
                                }).ToList(),
                            };
                        }).ToList();

                    ComboNotification notification = new ComboNotification();
                    notification.AddNew();
                    notification.ComboUserID = post.ComboUserID;
                    notification.NotificationType = (int)Combo.Models.NotificationType.LIKE; // like
                    notification.NotificationDate = DateTime.UtcNow;
                    notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(alike);
                    notification.IsRead = false;
                    notification.Save();

                    NotificationUserSettings settings = new NotificationUserSettings();
                    settings.LoadByPrimaryKey(creator.ComboUserID, (int)Combo.Models.NotificationType.LIKE);
                    bool notify = false;
                    if (settings.RowCount == 0)
                        notify = true;
                    else
                        notify = settings.CanGetNotification(creator.ComboUserID, liker.ComboUserID, (int)Combo.Models.NotificationType.LIKE);
                    if (notify)
                    {
                        List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                            {
                                return new Models.ComboNotification
                                {
                                    ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                                    IsRead = Convert.ToBoolean(row["IsRead"]),
                                    NotificationBody = row["NotificationBody"].ToString(),
                                    NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                                    NotificationType = Convert.ToInt32(row["NotificationType"])
                                };
                            }
                            ).ToList();

                        string notification_response = SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), creator.DeviceID);
                    }
                }
            }
            else
            {
                likes.MarkAsDeleted();
                likes.Save();
            }

            likes.GetPostLikesByPostID(id);

            List<Models.ComboPostLike> Alllikes = likes.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboPostLike
                {
                    ComboPostID = Convert.ToInt32(row["ComboPostID"]),
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    UserName = row["UserName"].ToString(),
                    DisplayName = row["DisplayName"].ToString(),
                };
            }).ToList();

            _response.Entity = Alllikes;
            SetContentResult(_response);
        }
Ejemplo n.º 7
0
        public void ToggleIsDownloadablePosts(int userid, bool IsDownloadable)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUserSettings setting = new ComboUserSettings();
            if (!setting.GetSettingsByUserId(userid))
            {
                setting.AddNew();
                setting.IsPostsDownloadable = IsDownloadable;
                setting.ComboUserID = userid;
                setting.Save();
            }
            else
            {
                setting.IsPostsDownloadable = IsDownloadable;
                setting.Save();
            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 8
0
        public void ToggleFavouritePostByID(int id, int userid)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboPostFav fav = new ComboPostFav();
            if (!fav.LoadByPrimaryKey(userid, id))
            {
                fav.AddNew();
                fav.ComboPostID = id;
                fav.ComboUserID = userid;
                fav.Save();

            }
            else
            {
                fav.MarkAsDeleted();
                fav.Save();
            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 9
0
        public void RespondToFriendRequest(int userId, int FriendId, bool isAccepted)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUserFriend friend = new ComboUserFriend();
            if (friend.LoadByPrimaryKey(userId, FriendId))
            {
                if (isAccepted)
                {
                    friend.RequestApproved = true;
                }
                else
                {
                    friend.MarkAsDeleted();
                }
                friend.Save();

                if (isAccepted)
                {
                    /**************************/
                    // save notification and push it to device
                    ComboUser creator = new ComboUser();
                    ComboUser requester = new ComboUser();
                    creator.LoadByPrimaryKey(userId);
                    requester.LoadByPrimaryKey(FriendId);

                    List<Models.ComboFriendRequest> arequest = friend.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboFriendRequest
                        {
                            ComboFriendID = Convert.ToInt32(row["ComboFriendID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            ComboUserName = creator.UserName,
                            ComboFriendName = requester.UserName,
                            ComboFriendDisplayName = requester.DisplayName
                        };
                    }).ToList();

                    ComboNotification notification = new ComboNotification();
                    notification.AddNew();
                    notification.ComboUserID = requester.ComboUserID;
                    notification.NotificationType = (int)Combo.Models.NotificationType.ACCEPT_FRIEND; // accept friend request
                    notification.NotificationDate = DateTime.UtcNow;
                    notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(arequest);
                    notification.IsRead = false;
                    notification.Save();

                    List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboNotification
                        {
                            ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            IsRead = Convert.ToBoolean(row["IsRead"]),
                            NotificationBody = row["NotificationBody"].ToString(),
                            NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                            NotificationType = Convert.ToInt32(row["NotificationType"])
                        };
                    }).ToList();

                    SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), requester.DeviceID);
                    /**************************/
                }
            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 10
0
        public void ReportPost(int id, string description)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboPostReport post = new ComboPostReport();
            post.AddNew();
            post.ComboPostID = id;
            post.ReportDate = DateTime.UtcNow;
            post.ReportText = description;
            post.Save();

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 11
0
        public void GetUsers()
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUser user = new ComboUser();
            user.LoadAll();
            List<Models.ComboUser> Users = user.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboUser
                {
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    UserName = row["UserName"].ToString(),
                    DisplayName = row["DisplayName"].ToString(),
                    Password = row["Password"].ToString(),
                    Email = row["Email"].ToString(),
                    Bio = row["Bio"].ToString(),
                    ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                    CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                    GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                    IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                    ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                    ExternalID = row["ExternalID"].ToString(),
                    DeviceID = row["DeviceID"].ToString(),
                    ActivationCode = row.IsNull("ActivationCode") ? Guid.Empty : new Guid(row["ActivationCode"].ToString()),
                    PassResetCode = row.IsNull("PassResetCode") ? Guid.Empty : new Guid(row["PassResetCode"].ToString()),
                    UserRankID = Convert.ToInt32(row["UserRankID"]),
                    Location = row["Location"].ToString()
                };
            }).ToList();

            _response.Entity = Users;
            SetContentResult(_response);
            //return _response;
        }
Ejemplo n.º 12
0
        public void GetUserInfoByID(int id)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUser user = new ComboUser();
            user.GetUserByUserId(id);

            ComboComment comments = new ComboComment();
            comments.GetPostCommentsCountByUserID(user.ComboUserID);

            UserActivityLog log = new UserActivityLog();
            log.GetActivityDaysByUserID(user.ComboUserID);

            ComboUser stats = new ComboUser();
            stats.GetUserStatisticsByUserId(id);

            List<Models.ComboUser> Users = user.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboUser
                {
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    UserName = row["UserName"].ToString(),
                    DisplayName = row["DisplayName"].ToString(),
                    Password = row["Password"].ToString(),
                    Email = row["Email"].ToString(),
                    Bio = row["Bio"].ToString(),
                    ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                    CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                    GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                    IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                    ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                    ExternalID = row["ExternalID"].ToString(),
                    DeviceID = row["DeviceID"].ToString(),
                    ActivationCode = row.IsNull("ActivationCode") ? Guid.Empty : new Guid(row["ActivationCode"].ToString()),
                    PassResetCode = row.IsNull("PassResetCode") ? Guid.Empty : new Guid(row["PassResetCode"].ToString()),
                    FollowersCount = Convert.ToInt32(stats.GetColumn("FollowersCount")),
                    FollowingCount = Convert.ToInt32(stats.GetColumn("FollowingsCount")),
                    FriendsCount = Convert.ToInt32(stats.GetColumn("FriendsCount")),
                    PostsCount = Convert.ToInt32(stats.GetColumn("PostsCount")),
                    PostsLikeCount = Convert.ToInt32(stats.GetColumn("PostsLikeCount")),
                    ProfilePic = row["ProfilePic"].ToString(),
                    SecurityQuestion = row["SecurityQuestion"].ToString(),
                    SecurityAnswer = row["SecurityAnswer"].ToString(),
                    UserRankID = Convert.ToInt32(row["UserRankID"]),
                    ProfileLikerCount = Convert.ToInt32(stats.GetColumn("ProfileLikerCount")),
                    SecurityWord = row["SecurityWord"].ToString(),
                    CountryFlagPath = row["CountryFlagPath"].ToString(),
                    Location = row["Location"].ToString(),
                    TotalActivityDays = log.RowCount > 0 ? Convert.ToInt32(log.GetColumn("TotalActivityDays")) : 0,
                    CommentsCount = Convert.ToInt32(comments.GetColumn("TotalCount"))
                };
            }).ToList();

            _response.Entity = Users;
            SetContentResult(_response);
        }
Ejemplo n.º 13
0
        public void AddMessage(Models.ComboMessage msg)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            if (string.IsNullOrEmpty(msg.ToIds))
            {
                _response.ErrorCode = 30;
                _response.ErrorMsg = "Can't add Msg. No to id .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            if (msg.ToIds.Split(',').Length == 0)
            {
                _response.ErrorCode = 30;
                _response.ErrorMsg = "Can't add Msg. No to idsor error in format .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            BLL.ComboMsg newMsg = new ComboMsg();
            newMsg.AddNew();

            if (msg.ComboUserID != 0)
                newMsg.ComboUserID = msg.ComboUserID;
            else
            {
                _response.ErrorCode = 30;
                _response.ErrorMsg = "Can't add Msg. No user id .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            newMsg.MsgText = msg.MsgText.Replace("\n", " "); ;
            newMsg.MsgDate = DateTime.UtcNow;
            newMsg.IsRead = false;
            newMsg.Save();

            string[] ToIds = msg.ToIds.Split(',');
            ComboUserMsg tomsg = new ComboUserMsg();
            foreach (string item in ToIds)
            {
                tomsg.AddNew();
                tomsg.ComboUserID = Convert.ToInt32(item);
                tomsg.ComboMsgID = newMsg.ComboMsgID;
            }
            tomsg.Save();

            /**************************/
            // save notification and push it to device
            ComboUser creator = new ComboUser();
            ComboUser commentor = new ComboUser();
            creator.GetUserByUserId(newMsg.ComboUserID);

            List<Models.ComboMessage> amsg = newMsg.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboMessage
                {
                    ComboMsgID = Convert.ToInt32(row["ComboMsgID"]),
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    ComboUserName = creator.UserName,
                    ComboUserDisplayName = creator.DisplayName,
                    MsgText = newMsg.MsgText,
                    MsgDate = newMsg.MsgDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                    ProfilePic = creator.GetColumn("ProfilePic").ToString()
                };
            }).ToList();

            foreach (string item in ToIds)
            {
                ComboNotification notification = new ComboNotification();
                notification.AddNew();
                notification.ComboUserID = Convert.ToInt32(item);
                notification.NotificationType = (int)Combo.Models.NotificationType.RECEIVE_MSG; // new Msg recieved
                notification.NotificationDate = DateTime.UtcNow;
                notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(amsg);
                notification.IsRead = false;
                notification.Save();

                commentor.GetUserByUserId(Convert.ToInt32(item));

                NotificationUserSettings settings = new NotificationUserSettings();
                settings.LoadByPrimaryKey(Convert.ToInt32(item), (int)Combo.Models.NotificationType.RECEIVE_MSG);
                bool notify = false;
                if (settings.RowCount == 0)
                    notify = true;
                else
                    notify = settings.CanGetNotification(commentor.ComboUserID, creator.ComboUserID, (int)Combo.Models.NotificationType.FOLLOW_FIREND);
                if (notify)
                {
                    List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboNotification
                        {
                            ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            IsRead = Convert.ToBoolean(row["IsRead"]),
                            NotificationBody = row["NotificationBody"].ToString(),
                            NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                            NotificationType = Convert.ToInt32(row["NotificationType"])
                        };
                    }).ToList();

                    SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), commentor.DeviceID);
                }
            }
            /**************************/

            JavaScriptSerializer js = new JavaScriptSerializer();
            Models.Attachment[] att = js.Deserialize<Models.Attachment[]>(js.Serialize(msg.Attachments));

            ComboMsgAttachment attachment = new ComboMsgAttachment();
            foreach (Models.Attachment item in att)
            {
                attachment.AddNew();
                attachment.AttachmentID = item.AttachmentID;
                attachment.ComboMsgID = newMsg.ComboMsgID;

            }
            attachment.Save();

            msg.ComboMsgID = newMsg.ComboMsgID;
            msg.MsgDate = newMsg.MsgDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            _response.Entity = new Models.ComboMessage[] { msg };

            SetContentResult(_response);
            return;
        }
Ejemplo n.º 14
0
        public void GetUserByID(int id, int requester)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUser user = new ComboUser();
            user.GetUserByUserId(id, requester);

            ComboUser stats = new ComboUser();
            stats.GetUserStatisticsByUserId(id);

            List<Models.ComboUser> Users = user.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboUser
                {
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    UserName = row["UserName"].ToString(),
                    DisplayName = row["DisplayName"].ToString(),
                    Password = row["Password"].ToString(),
                    Email = row["Email"].ToString(),
                    Bio = row["Bio"].ToString(),
                    ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                    CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                    GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                    IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                    ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                    ExternalID = row["ExternalID"].ToString(),
                    DeviceID = row["DeviceID"].ToString(),
                    ActivationCode = row.IsNull("ActivationCode") ? Guid.Empty : new Guid(row["ActivationCode"].ToString()),
                    PassResetCode = row.IsNull("PassResetCode") ? Guid.Empty : new Guid(row["PassResetCode"].ToString()),
                    FollowersCount = Convert.ToInt32(stats.GetColumn("FollowersCount")),
                    FollowingCount = Convert.ToInt32(stats.GetColumn("FollowingsCount")),
                    FriendsCount = Convert.ToInt32(stats.GetColumn("FriendsCount")),
                    PostsCount = Convert.ToInt32(stats.GetColumn("PostsCount")),
                    PostsLikeCount = Convert.ToInt32(stats.GetColumn("PostsLikeCount")),
                    IsFriend = Convert.ToBoolean(row["IsFriend"]),
                    IsFollower = Convert.ToBoolean(row["IsFollower"]),
                    IsFollowing = Convert.ToBoolean(row["IsFollowing"]),
                    FriendRequestSent = Convert.ToInt32(row["IsFriendRequestSent"]),
                    ProfilePic = row["ProfilePic"].ToString(),
                    CoverPic = row["CoverPic"].ToString(),
                    UserRankID = Convert.ToInt32(row["UserRankID"]),
                    ProfileLikerCount = Convert.ToInt32(stats.GetColumn("ProfileLikerCount")),
                    BirthDate = row.IsNull("BirthDate") ? DateTime.MinValue : Convert.ToDateTime(row["BirthDate"]),
                    Country  = row["Country"].ToString(),
                    Phone = row["Phone"].ToString(),
                    Website = row["Website"].ToString(),
                    CountryFlagPath = row["CountryFlagPath"].ToString(),
                    Location = row["Location"].ToString(),
                    IsPrivateAccount = row.IsNull("IsPrivateAccount") ? false : Convert.ToBoolean(row["IsPrivateAccount"]),
                    IsFollowingRequestSent = Convert.ToBoolean(row["IsFollowingRequestSent"]),
                    IsFollowerRequestSent = Convert.ToBoolean(row["IsFollowerRequestSent"]),
                    IsBlocked = Convert.ToBoolean(row["IsBlocked"])
                };
            }).ToList();

            _response.Entity = Users;
            SetContentResult(_response);
        }
Ejemplo n.º 15
0
        public void GetUser(string username, string password, string DeviceID)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUser user = new ComboUser();
            if (!user.GetUserByUserNameAndPassword(username, password))
            {
                _response.ErrorCode = 11;
                _response.ErrorMsg = "User doesn't exist";
                _response.bool_result = false;
                if (user.GetUserByUserName(username))
                {
                    _response.ErrorCode = 10;
                    _response.ErrorMsg = "Password not correct";
                }
            }
            else
            {
                // save device id if changed
                user.DeviceID = DeviceID;
                user.Save();
                // get user info
                List<Models.ComboUser> Users = user.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.ComboUser
                    {
                        ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                        UserName = row["UserName"].ToString(),
                        DisplayName = row["DisplayName"].ToString(),
                        Password = row["Password"].ToString(),
                        Email = row["Email"].ToString(),
                        Bio = row["Bio"].ToString(),
                        ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                        CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                        GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                        IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                        ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                        ExternalID = row["ExternalID"].ToString(),
                        DeviceID = row["DeviceID"].ToString(),
                        ActivationCode = row.IsNull("ActivationCode") ? Guid.Empty : new Guid(row["ActivationCode"].ToString()),
                        PassResetCode = row.IsNull("PassResetCode") ? Guid.Empty : new Guid(row["PassResetCode"].ToString()),
                        SecurityQuestion = row["SecurityQuestion"].ToString(),
                        SecurityAnswer = row["SecurityAnswer"].ToString(),
                        UserRankID = Convert.ToInt32(row["UserRankID"]),
                        SecurityWord = row["SecurityWord"].ToString(),
                        Location = row["Location"].ToString()
                    };
                }).ToList();

                _response.Entity = Users;
            }
            SetContentResult(_response);
            return;
        }
Ejemplo n.º 16
0
        public void ToggleBlockUser(int userId, int BlockedUserID)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";
            bool block = false;

            BlockedUser blocked = new BlockedUser();
            if (!blocked.LoadByPrimaryKey(userId, BlockedUserID))
            {
                blocked.AddNew();
                blocked.BlockedUserID = BlockedUserID;
                blocked.ComboUserID = userId;
                blocked.Save();
                block = true;
            }
            else
            {
                blocked.MarkAsDeleted();
                blocked.Save();
            }

            if (block)
            {
                ProfileFollower _1stfollow = new ProfileFollower();
                ProfileFollower _2ndfollow = new ProfileFollower();
                if (_1stfollow.LoadByPrimaryKey(userId, BlockedUserID))
                {
                    _1stfollow.MarkAsDeleted();
                    _1stfollow.Save();
                }
                if (_2ndfollow.LoadByPrimaryKey(BlockedUserID, userId))
                {
                    _2ndfollow.MarkAsDeleted();
                    _2ndfollow.Save();
                }
            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 17
0
        public void ToggleDeactivateUser(int ID, bool deactivate)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUser user = new ComboUser();
            if (!user.LoadByPrimaryKey(ID))
            {
                _response.ErrorCode = 11;
                _response.ErrorMsg = "User doesn't exist";
                _response.bool_result = false;

            }
            else
            {
                user.IsDeactivated = deactivate;
                user.Save();
            }

            _response.Entity = null;
            SetContentResult(_response);
            return;
        }
Ejemplo n.º 18
0
        public void SearchHashTagByName(string hashTag)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            HashTag tags = new HashTag();
            tags.GetHashTagByName(hashTag);
            List<Models.HashTag> Tags = tags.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.HashTag
                {
                    HashTagID = Convert.ToInt32(row["HashTagID"]),
                    TagName = row["Name"].ToString()
                };
            }).ToList();

            _response.Entity = Tags;
            SetContentResult(_response);
            //return _response;
        }
Ejemplo n.º 19
0
        public void ToggleFollowFriend(int userId, int FollowerId)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";
            bool follow = false;

            ProfileFollower follower = new ProfileFollower();
            if (!follower.LoadByPrimaryKey(userId, FollowerId))
            {
                follower.AddNew();
                follower.ComboFollowerID = FollowerId;
                follower.ComboUserID = userId;
                follower.IsRequestApproved = true;
                follower.Save();
                follow = true;
            }
            else
            {
                follower.MarkAsDeleted();
                follower.Save();
            }

            if (follow)
            {
                /**************************/
                // save notification and push it to device
                ComboUser creator = new ComboUser();
                ComboUser commentor = new ComboUser();
                creator.GetUserByUserId(userId);
                commentor.GetUserByUserId(FollowerId);

                List<Models.FollowRequest> arequest = follower.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.FollowRequest
                    {
                        ComboFriendID = Convert.ToInt32(row["ComboFollowerID"]),
                        ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                        ComboUserName = commentor.UserName,
                        ComboDisplayName = commentor.DisplayName,
                        ProfilePic = creator.GetColumn("ProfilePic").ToString(),
                        FriendProfilePic = commentor.GetColumn("ProfilePic").ToString(),
                        IsFollowUser = follow
                    };
                }).ToList();

                ComboNotification notification = new ComboNotification();
                notification.AddNew();
                notification.ComboUserID = creator.ComboUserID;
                if (follow)
                    notification.NotificationType = (int)Combo.Models.NotificationType.FOLLOW_FIREND; // follow friend
                else
                    notification.NotificationType = (int)Combo.Models.NotificationType.UNFOLLOW_FRIEND; // unfollow friend
                notification.NotificationDate = DateTime.UtcNow;
                notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(arequest);
                notification.IsRead = false;
                notification.Save();

                NotificationUserSettings settings = new NotificationUserSettings();
                settings.LoadByPrimaryKey(creator.ComboUserID, (int)Combo.Models.NotificationType.FOLLOW_FIREND);
                bool notify = false;
                if (settings.RowCount == 0)
                    notify = true;
                else
                    notify = settings.CanGetNotification(creator.ComboUserID, commentor.ComboUserID, (int)Combo.Models.NotificationType.FOLLOW_FIREND);
                if (notify)
                {
                    List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboNotification
                        {
                            ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            IsRead = Convert.ToBoolean(row["IsRead"]),
                            NotificationBody = row["NotificationBody"].ToString(),
                            NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                            NotificationType = Convert.ToInt32(row["NotificationType"])
                        };
                    }).ToList();

                    SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), creator.DeviceID);
                }
                /**************************/
            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 20
0
        public void SearchOnFriends(int userID, string searchText, int pageIndex)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUserFriend user = new ComboUserFriend();
            user.SearchOnFriendsByUserID(userID, searchText);
            List<Models.ComboUser> Users = user.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboUser
                {
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    UserName = row["UserName"].ToString(),
                    DisplayName = row["DisplayName"].ToString(),
                    Password = row["Password"].ToString(),
                    Email = row["Email"].ToString(),
                    Bio = row["Bio"].ToString(),
                    ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                    CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                    GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                    IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                    ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                    ExternalID = row["ExternalID"].ToString(),
                    DeviceID = row["DeviceID"].ToString(),
                    ActivationCode = row.IsNull("ActivationCode") ? Guid.Empty : new Guid(row["ActivationCode"].ToString()),
                    PassResetCode = row.IsNull("PassResetCode") ? Guid.Empty : new Guid(row["PassResetCode"].ToString()),
                    ProfilePic = row["ProfilePic"].ToString(),
                };
            }).Skip(pageIndex * FriendsPageSize).Take(FriendsPageSize).ToList();

            _response.Entity = Users;
            SetContentResult(_response);
            //return _response;
        }
Ejemplo n.º 21
0
        public void ToggleLikeFriend(int userId, int LikerId)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";
            bool like = false;

            ProfileLiker Liker = new ProfileLiker();
            if (!Liker.LoadByPrimaryKey(userId, LikerId))
            {
                Liker.AddNew();
                Liker.ComboLikerID = LikerId;
                Liker.ComboUserID = userId;
                Liker.Save();
                like = true;
            }
            else
            {
                Liker.MarkAsDeleted();
                Liker.Save();
            }

            /**************************/
            // save notification and push it to device
            ComboUser creator = new ComboUser();
            ComboUser P_Liker = new ComboUser();
            creator.LoadByPrimaryKey(userId);
            P_Liker.LoadByPrimaryKey(LikerId);

            ComboNotification notification = new ComboNotification();
            notification.AddNew();
            notification.ComboUserID = creator.ComboUserID;
            if (like)
                notification.NotificationType = (int)Combo.Models.NotificationType.LIKE_PROFILE; // Like friend
            else
                notification.NotificationType = (int)Combo.Models.NotificationType.UNLIKE_PROFILE; // unLike friend
            notification.NotificationDate = DateTime.UtcNow;
            notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject("[{'ComboUserID':" + creator.ComboUserID + ",'ComboFriendID':" + P_Liker.ComboUserID + ",'ComboUsername:'******'" + ",'ComboDisplayName:'" + P_Liker.DisplayName + "', 'IsFollowUser' : " + like + "}]");
            notification.IsRead = false;
            notification.Save();

            List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboNotification
                {
                    ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    IsRead = Convert.ToBoolean(row["IsRead"]),
                    NotificationBody = row["NotificationBody"].ToString(),
                    NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                    NotificationType = Convert.ToInt32(row["NotificationType"])
                };
            }).ToList();

            SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), creator.DeviceID);
            /**************************/

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 22
0
        public void SearchPosts(string filterText, int requester,int Page)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboPost posts = new ComboPost();
            posts.SearchPosts(filterText, requester);
            List<Models.ComboPost> Posts = posts.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboPost
                {
                    ComboPostID = Convert.ToInt32(row["ComboPostID"]),
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    ComboUserName = row["UserName"].ToString(),
                    ProfilePic = row["ProfilePic"].ToString(),
                    PostText = row["PostText"].ToString(),
                    PostDate = Convert.ToDateTime(row["PostDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                    IsDownloadable = (row["IsPostsDownloadable"] == DBNull.Value) ? false : Convert.ToBoolean(row["IsPostsDownloadable"])
                };
            }).Skip(Page * PostsPageSize).Take(PostsPageSize).ToList();

            foreach (Models.ComboPost item in Posts)
            {
                ComboPostLike likes = new ComboPostLike();
                likes.GetPostLikesByPostID(item.ComboPostID);
                item.Likes = likes.DefaultView.Table.AsEnumerable().Select(r =>
                {
                    return new Models.ComboPostLike
                    {
                        ComboPostID = Convert.ToInt32(r["ComboPostID"]),
                        ComboUserID = Convert.ToInt32(r["ComboUserID"]),
                        UserName = r["UserName"].ToString(),
                    };
                }).ToList();

                ComboComment totalCount = new ComboComment();
                totalCount.GetPostCommentsCount(item.ComboPostID);

                item.CommentsCount = Convert.ToInt32(totalCount.GetColumn("TotalCount"));

                ComboPostShare shareCount = new ComboPostShare();
                shareCount.GetPostShareCount(item.ComboPostID);

                item.ShareCount = Convert.ToInt32(shareCount.GetColumn("TotalCount"));

                ComboComment comments = new ComboComment();
                comments.GetTopPostCommentsByPostID(item.ComboPostID);
                // get top 3 comments for each post
                item.Comments = comments.DefaultView.Table.AsEnumerable().Select(r =>
                {
                    return new Models.ComboComment
                    {
                        ComboCommentID = Convert.ToInt32(r["ComboCommentID"]),
                        ComboPostID = Convert.ToInt32(r["ComboPostID"]),
                        ComboUserID = Convert.ToInt32(r["ComboUserID"]),
                        ComboUserName = r["UserName"].ToString(),
                        ProfilePic = r["ProfilePic"].ToString(),
                        CommentText = r["CommentText"].ToString(),
                        CommentDate = Convert.ToDateTime(r["CommentDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                    };
                }).ToList();

                List<Models.ComboComment> _comm = item.Comments as List<Models.ComboComment>;
                foreach (Models.ComboComment _itemcomm in _comm)
                {
                    ComboCommentLike c_likes = new ComboCommentLike();
                    ComboCommentAttachment c_attachments = new ComboCommentAttachment();
                    c_likes.GetCommentLikesByCommentID(_itemcomm.ComboCommentID);
                    c_attachments.GetCommentAttachmentsByCommentID(_itemcomm.ComboCommentID);
                    _itemcomm.Likes = c_likes.DefaultView.Table.AsEnumerable().Select(r =>
                    {
                        return new Models.ComboCommentLike
                        {
                            ComboCommentID = Convert.ToInt32(r["ComboCommentID"]),
                            ComboUserID = Convert.ToInt32(r["ComboUserID"]),
                            UserName = r["UserName"].ToString(),
                        };
                    }).ToList();
                    _itemcomm.Attachments = c_attachments.DefaultView.Table.AsEnumerable().Select(r =>
                    {
                        return new Models.Attachment
                        {
                            AttachmentID = Convert.ToInt32(r["AttachmentID"]),
                            Path = r["Path"].ToString(),
                            AttachmentTypeID = Convert.ToInt32(r["AttachmentTypeID"]),
                            ThumbsPath = r["ThumbsPath"].ToString()
                        };
                    }).ToList();

                    // get user mention
                    CommentUserTag CommentuserTags = new CommentUserTag();
                    CommentuserTags.GetUserTagsByCommentID(_itemcomm.ComboCommentID);
                    _itemcomm.UserTags = CommentuserTags.DefaultView.Table.AsEnumerable().Select(r =>
                    {
                        return new Models.CommentUserTag
                        {
                            ComboCommentID = Convert.ToInt32(r["ComboCommentID"]),
                            UserName = r["Username"].ToString(),
                            ComboUserID = Convert.ToInt32(r["ComboUserID"]),
                            Offset = Convert.ToInt32(r["Offset"])
                        };
                    }).ToList();

                    // get hashtags
                    CommentHashTag Commenthastags = new CommentHashTag();
                    Commenthastags.GetHashTagsByCommnetID(_itemcomm.ComboCommentID);
                    _itemcomm.HashTags = Commenthastags.DefaultView.Table.AsEnumerable().Select(r =>
                    {
                        return new Models.CommentHashTag
                        {
                            HashTagID = Convert.ToInt32(r["HashTagID"]),
                            TagName = r["Name"].ToString(),
                            Offset = Convert.ToInt32(r["Offset"])
                        };
                    }).ToList();
                }

                item.Comments = _comm;

                ComboPostAttachment attachments = new ComboPostAttachment();
                attachments.GetPostAttachmentsByPostID(item.ComboPostID);
                item.Attachments = attachments.DefaultView.Table.AsEnumerable().Select(r =>
                {
                    return new Models.Attachment
                    {
                        AttachmentID = Convert.ToInt32(r["AttachmentID"]),
                        Path = r["Path"].ToString(),
                        AttachmentTypeID = Convert.ToInt32(r["AttachmentTypeID"]),
                        ThumbsPath = r["ThumbsPath"].ToString()
                    };
                }).ToList();

                // get user mention
                PostUserTag userTags = new PostUserTag();
                userTags.GetUserTagsByPostID(item.ComboPostID);
                item.UserTags = userTags.DefaultView.Table.AsEnumerable().Select(r =>
                {
                    return new Models.PostUserTag
                    {
                        ComboPostID = Convert.ToInt32(r["ComboPostID"]),
                        UserName = r["Username"].ToString(),
                        ComboUserID = Convert.ToInt32(r["ComboUserID"]),
                        Offset = Convert.ToInt32(r["Offset"])
                    };
                }).ToList();

                // get hashtags
                PostHashTag hastags = new PostHashTag();
                hastags.GetHashTagsByPostID(item.ComboPostID);
                item.HashTags = hastags.DefaultView.Table.AsEnumerable().Select(r =>
                {
                    return new Models.PostHashTag
                    {
                        HashTagID = Convert.ToInt32(r["HashTagID"]),
                        TagName = r["Name"].ToString(),
                        Offset = Convert.ToInt32(r["Offset"])
                    };
                }).ToList();
            }

            _response.Entity = Posts;
            SetContentResult(_response);
            //return _response;
        }
Ejemplo n.º 23
0
        public void ToggleNotificationIsRead(int id, bool isRead)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboNotification notification = new ComboNotification();
            if (notification.LoadByPrimaryKey(id))
            {
                notification.IsRead = isRead;
                notification.Save();

            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 24
0
        public void SetNotificationSettings(object NotificationUserSetting)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            NotificationUserSettings setting = new NotificationUserSettings();
            JavaScriptSerializer js = new JavaScriptSerializer();
            Models.NotificationUserSetting[] usersettings = js.Deserialize<Models.NotificationUserSetting[]>(js.Serialize(NotificationUserSetting));
            if (usersettings != null)
            {
                foreach (Models.NotificationUserSetting item in usersettings)
                {
                    if (!setting.LoadByPrimaryKey(item.ComboUserID, item.NotificationTypeID))
                    {
                        setting.AddNew();
                        setting.NotificationTypeID = item.NotificationTypeID;
                        setting.ComboUserID = item.ComboUserID;
                        setting.Status = item.Status;
                        setting.Save();
                    }
                    else
                    {
                        setting.Status = item.Status;
                        setting.Save();
                    }
                }

            }

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 25
0
        public void UpdateUser(Models.ComboUser user)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            BLL.ComboUser newUser = new ComboUser();
            newUser.LoadByPrimaryKey(user.ComboUserID);
            if (!string.IsNullOrEmpty(user.DisplayName))
                newUser.DisplayName = user.DisplayName;
            if (!string.IsNullOrEmpty(user.Password))
                newUser.Password = user.Password;
            if (!string.IsNullOrEmpty(user.Email))
                newUser.Email = user.Email;
            if (!string.IsNullOrEmpty(user.Bio))
                newUser.Bio = user.Bio;
            if (user.ProfileImgID != 0)
                newUser.ProfileImgID = user.ProfileImgID;
            if (user.CoverImgID != 0)
                newUser.CoverImgID = user.CoverImgID;
            if (user.GenderID != 0)
                newUser.GenderID = user.GenderID;

            if (!string.IsNullOrEmpty(user.SecurityQuestion))
                newUser.SecurityQuestion = user.SecurityQuestion;
            if (!string.IsNullOrEmpty(user.SecurityAnswer))
                newUser.SecurityAnswer = user.SecurityAnswer;
            if (!string.IsNullOrEmpty(user.SecurityWord))
                newUser.SecurityWord = user.SecurityWord;

            if (user.ExternalIDType != 0)
            {
                newUser.ExternalIDType = user.ExternalIDType;
                newUser.ExternalID = user.ExternalID;
            }
            if (!string.IsNullOrEmpty(user.DeviceID))
                newUser.DeviceID = user.DeviceID;

            if (user.BirthDate != DateTime.MinValue)
                newUser.BirthDate = user.BirthDate;
            if (!string.IsNullOrEmpty(user.Country))
                newUser.Country = user.Country;
            if (!string.IsNullOrEmpty(user.Phone))
                newUser.Phone = user.Phone;
            if (!string.IsNullOrEmpty(user.Website))
                newUser.Website = user.Website;
            if (user.CountryID != 0)
                newUser.CountryID = user.CountryID;
            if (!string.IsNullOrEmpty(user.Location))
                newUser.Location = user.Location;

            try
            {
                newUser.IsPrivateAccount = user.IsPrivateAccount;
            }
            catch (Exception ex)
            {

            }

            newUser.Save();

            user.ComboUserID = newUser.ComboUserID;
            user.UserRankID = newUser.UserRankID;

            _response.Entity = new Models.ComboUser[]{ user};

            SetContentResult(_response);
            return;
        }
Ejemplo n.º 26
0
        public void SharePost(int PostId, int UserId)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboPostShare post = new ComboPostShare();
            post.AddNew();
            post.ComboPostID = PostId;
            post.ShareDate = DateTime.UtcNow;
            post.ComboUserID = UserId;
            post.Save();

            /**************************/
            // save notification and push it to device
            ComboPost ref_post = new ComboPost();
            ref_post.LoadByPrimaryKey(PostId);

            ComboPostAttachment att = new ComboPostAttachment();
            att.GetPostAttachmentsByPostID(PostId);

            ComboUser creator = new ComboUser();
            ComboUser requester = new ComboUser();
            creator.LoadByPrimaryKey(ref_post.ComboUserID);
            requester.LoadByPrimaryKey(UserId);
            if (creator.ComboUserID != requester.ComboUserID)
            {
                List<Models.ComboSharePost> info = post.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.ComboSharePost
                    {
                        ComboFriendID = requester.ComboUserID,
                        ComboUserID = creator.ComboUserID,
                        ComboUserName = creator.UserName,
                        ComboFriendName = requester.UserName,
                        ComboFriendDisplayName = requester.DisplayName,
                        ComboPostID = Convert.ToInt32(row["ComboPostID"].ToString()),
                        PostText = ref_post.PostText,
                        Attachments = att.DefaultView.Table.AsEnumerable().Select(r =>
                        {
                            return new Models.Attachment
                            {
                                AttachmentID = Convert.ToInt32(r["AttachmentID"]),
                                Path = r["Path"].ToString(),
                                AttachmentTypeID = Convert.ToInt32(r["AttachmentTypeID"]),
                                ThumbsPath = r["ThumbsPath"].ToString()
                            };
                        }).ToList(),
                    };
                }).ToList();

                ComboNotification notification = new ComboNotification();
                notification.AddNew();
                notification.ComboUserID = creator.ComboUserID;
                notification.NotificationType = (int)Combo.Models.NotificationType.SHARE_POST; // share post
                notification.NotificationDate = DateTime.UtcNow;
                notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(info);
                notification.IsRead = false;
                notification.Save();

                NotificationUserSettings settings = new NotificationUserSettings();
                settings.LoadByPrimaryKey(creator.ComboUserID, (int)Combo.Models.NotificationType.SHARE_POST);
                bool notify = false;
                if (settings.RowCount == 0)
                    notify = true;
                else
                    notify = settings.CanGetNotification(creator.ComboUserID, requester.ComboUserID, (int)Combo.Models.NotificationType.SHARE_POST);
                if (notify)
                {
                    List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboNotification
                        {
                            ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            IsRead = Convert.ToBoolean(row["IsRead"]),
                            NotificationBody = row["NotificationBody"].ToString(),
                            NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                            NotificationType = Convert.ToInt32(row["NotificationType"])
                        };
                    }).ToList();

                    SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), creator.DeviceID);
                }
            }
            /**************************/

            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 27
0
        public void AddComment(Models.ComboComment comment)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            BLL.ComboComment newComment = new ComboComment();
            newComment.AddNew();

            if (comment.ComboUserID != 0)
                newComment.ComboUserID = comment.ComboUserID;
            else
            {
                _response.ErrorCode = 30;
                _response.ErrorMsg = "Can't insert commnet. No user id .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            if (comment.ComboPostID != 0)
                newComment.ComboPostID = comment.ComboPostID;
            else
            {
                _response.ErrorCode = 31;
                _response.ErrorMsg = "Can't insert comment. No post id .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            newComment.CommentText = comment.CommentText.Replace("\n", " "); ;
            newComment.CommentDate = DateTime.UtcNow;

            newComment.Save();

            JavaScriptSerializer js = new JavaScriptSerializer();
            Models.Attachment[] att = js.Deserialize<Models.Attachment[]>(js.Serialize(comment.Attachments));
            if (att != null)
            {
                ComboCommentAttachment attachment = new ComboCommentAttachment();
                foreach (Models.Attachment item in att)
                {
                    attachment.AddNew();
                    attachment.AttachmentID = item.AttachmentID;
                    attachment.ComboCommnetID = newComment.ComboCommentID;

                }
                attachment.Save();
            }

            ComboCommentAttachment notificationAtt = new ComboCommentAttachment ();
            notificationAtt.GetCommentAttachmentsByCommentID(newComment.ComboCommentID);

            Models.CommentUserTag[] userTags = js.Deserialize<Models.CommentUserTag[]>(js.Serialize(comment.UserTags));
            if (userTags != null)
            {
                CommentUserTag usertag = new CommentUserTag();
                foreach (Models.CommentUserTag item in userTags)
                {
                    usertag.AddNew();
                    usertag.ComboUserID = item.ComboUserID;
                    usertag.ComboCommentID = newComment.ComboCommentID;
                    usertag.Offset = item.Offset;

                    /**************************/
                    // save notification and push it to device
                    ComboUser commentcreator = new ComboUser();
                    ComboUser tagged = new ComboUser();
                    commentcreator.GetUserByUserId(newComment.ComboUserID);
                    tagged.GetUserByUserId(item.ComboUserID);
                    List<Models.CommentUserTag> postTag = new List<Models.CommentUserTag>();
                    postTag.Add(new Models.CommentUserTag
                    {
                        ComboCommentID = newComment.ComboCommentID,
                        ComboUserID = tagged.ComboUserID,
                        UserName = tagged.UserName,
                        Offset = item.Offset,
                        ComboPostID = newComment.ComboPostID,
                        CreatorUserID = commentcreator.ComboUserID,
                        CreatorUserName= commentcreator.UserName,
                        CreatorProfilePic = commentcreator.GetColumn("ProfilePic").ToString(),
                        CommentText = newComment.CommentText,
                        Attachments = notificationAtt.DefaultView.Table.AsEnumerable().Select(r =>
                        {
                            return new Models.Attachment
                            {
                                AttachmentID = Convert.ToInt32(r["AttachmentID"]),
                                Path = r["Path"].ToString(),
                                AttachmentTypeID = Convert.ToInt32(r["AttachmentTypeID"]),
                                ThumbsPath = r["ThumbsPath"].ToString()
                            };
                        }).ToList(),
                    });

                    ComboNotification notification = new ComboNotification();
                    notification.AddNew();
                    notification.ComboUserID = tagged.ComboUserID;
                    notification.NotificationType = (int)Combo.Models.NotificationType.TAG_USER_IN_POST; // tag user to post
                    notification.NotificationDate = DateTime.UtcNow;
                    notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(postTag);
                    notification.IsRead = false;
                    notification.Save();

                    NotificationUserSettings settings = new NotificationUserSettings();
                    settings.LoadByPrimaryKey(tagged.ComboUserID, (int)Combo.Models.NotificationType.TAG_USER_IN_POST);
                    bool notify = false;
                    if (settings.RowCount == 0)
                        notify = true;
                    else
                        notify = settings.CanGetNotification(tagged.ComboUserID, commentcreator.ComboUserID, (int)Combo.Models.NotificationType.TAG_USER_IN_POST);
                    if (notify)
                    {
                        List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                        {
                            return new Models.ComboNotification
                            {
                                ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                                ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                                IsRead = Convert.ToBoolean(row["IsRead"]),
                                NotificationBody = row["NotificationBody"].ToString(),
                                NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                                NotificationType = Convert.ToInt32(row["NotificationType"])
                            };
                        }).ToList();

                        SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), tagged.DeviceID);
                    }
                    /**************************/

                }
                usertag.Save();
            }

            Models.CommentHashTag[] hashTags = js.Deserialize<Models.CommentHashTag[]>(js.Serialize(comment.HashTags));
            if (hashTags != null)
            {
                CommentHashTag commentthashtag = new CommentHashTag();

                foreach (Models.CommentHashTag item in hashTags)
                {
                    HashTag currenttag = new HashTag();

                    if (!currenttag.GetHashTagByName(item.TagName))
                    {
                        currenttag.AddNew();
                        currenttag.Name = item.TagName;
                        currenttag.Save();
                    }

                    commentthashtag.AddNew();
                    commentthashtag.HashTagID = currenttag.HashTagID;
                    commentthashtag.ComboCommentID = newComment.ComboCommentID;
                    commentthashtag.Offset = item.Offset;
                }
                commentthashtag.Save();
            }

            /**************************/
            // save notification and push it to device
            ComboPost post = new ComboPost();
            post.LoadByPrimaryKey(comment.ComboPostID);
            ComboUser creator = new ComboUser();
            ComboUser commentor = new ComboUser();
            ComboPostAttachment postatt = new ComboPostAttachment();
            postatt.GetPostAttachmentsByPostID(comment.ComboPostID);
            creator.GetUserByUserId(post.ComboUserID);
            commentor.GetUserByUserId(comment.ComboUserID);
            if (creator.ComboUserID != commentor.ComboUserID)
            {
                List<Models.ComboComment> acomment = newComment.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.ComboComment
                    {
                        ComboPostID = Convert.ToInt32(row["ComboPostID"]),
                        ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                        ComboUserName = commentor.UserName,
                        ComboDisplayName = commentor.DisplayName,
                        CommentText = newComment.CommentText,
                        CommentDate = newComment.CommentDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                        ProfilePic = commentor.GetColumn("ProfilePic").ToString(),
                        PostAttachemnts = postatt.DefaultView.Table.AsEnumerable().Select(r =>
                        {
                            return new Models.Attachment
                            {
                                AttachmentID = Convert.ToInt32(r["AttachmentID"]),
                                Path = r["Path"].ToString(),
                                AttachmentTypeID = Convert.ToInt32(r["AttachmentTypeID"]),
                                ThumbsPath = r["ThumbsPath"].ToString()
                            };
                        }).ToList(),
                    };
                }).ToList();

                ComboNotification notification = new ComboNotification();
                notification.AddNew();
                notification.ComboUserID = post.ComboUserID;
                notification.NotificationType = (int)Combo.Models.NotificationType.COMMENT_ON_POST; // add comment to post
                notification.NotificationDate = DateTime.UtcNow;
                notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(acomment);
                notification.IsRead = false;
                notification.Save();

                NotificationUserSettings settings = new NotificationUserSettings();
                settings.LoadByPrimaryKey(creator.ComboUserID, (int)Combo.Models.NotificationType.COMMENT_ON_POST);
                bool notify = false;
                if (settings.RowCount == 0)
                    notify = true;
                else
                    notify = settings.CanGetNotification(creator.ComboUserID, commentor.ComboUserID, (int)Combo.Models.NotificationType.COMMENT_ON_POST);
                if (notify)
                {
                    List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboNotification
                        {
                            ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            IsRead = Convert.ToBoolean(row["IsRead"]),
                            NotificationBody = row["NotificationBody"].ToString(),
                            NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                            NotificationType = Convert.ToInt32(row["NotificationType"])
                        };
                    }).ToList();

                    SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), creator.DeviceID);
                }
            }
            /**************************/

            comment.ComboCommentID = newComment.ComboCommentID;
            comment.CommentDate = newComment.CommentDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            _response.Entity = new Models.ComboComment[] { comment };

            SetContentResult(_response);
            return;
        }
Ejemplo n.º 28
0
        public void AddMessageComment(Models.ComboComment comment)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            BLL.ComboComment newComment = new ComboComment();
            newComment.AddNew();

            if (comment.ComboUserID != 0)
                newComment.ComboUserID = comment.ComboUserID;
            else
            {
                _response.ErrorCode = 30;
                _response.ErrorMsg = "Can't insert commnet. No user id .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            if (comment.ComboMsgID != 0)
                newComment.ComboMsgID = comment.ComboMsgID;
            else
            {
                _response.ErrorCode = 31;
                _response.ErrorMsg = "Can't insert comment. No Msg id .";
                _response.bool_result = false;
                SetContentResult(_response);
                return;
            }

            newComment.CommentText = comment.CommentText.Replace("\n", " "); ;
            newComment.CommentDate = DateTime.UtcNow;
            newComment.IsRead = false;
            newComment.Save();

            /**************************/
            // save notification and push it to device
            ComboMsg post = new ComboMsg();
            post.LoadByPrimaryKey(comment.ComboMsgID);
            ComboUser creator = new ComboUser();
            ComboUser commentor = new ComboUser();
            creator.LoadByPrimaryKey(post.ComboUserID);
            commentor.GetUserByUserId(comment.ComboUserID);

            if (creator.ComboUserID != commentor.ComboUserID)
            {
                List<Models.ComboComment> acomment = newComment.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.ComboComment
                    {
                        ComboMsgID = Convert.ToInt32(row["ComboMsgID"]),
                        ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                        ComboUserName = commentor.UserName,
                        ComboDisplayName = commentor.DisplayName,
                        CommentText = newComment.CommentText,
                        CommentDate = newComment.CommentDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                        ProfilePic = commentor.GetColumn("ProfilePic").ToString()
                    };
                }).ToList();

                ComboNotification notification = new ComboNotification();
                notification.AddNew();
                notification.ComboUserID = post.ComboUserID;
                notification.NotificationType = (int)Combo.Models.NotificationType.COMMENT_ON_MESSAGE; // add comment to post
                notification.NotificationDate = DateTime.UtcNow;
                notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(acomment);
                notification.IsRead = false;
                notification.Save();

                NotificationUserSettings settings = new NotificationUserSettings();
                settings.LoadByPrimaryKey(creator.ComboUserID, (int)Combo.Models.NotificationType.COMMENT_ON_MESSAGE);
                bool notify = false;
                if (settings.RowCount == 0)
                    notify = true;
                else
                    notify = settings.CanGetNotification(creator.ComboUserID, commentor.ComboUserID, (int)Combo.Models.NotificationType.COMMENT_ON_MESSAGE);
                if (notify)
                {
                    List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                    {
                        return new Models.ComboNotification
                        {
                            ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                            ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                            IsRead = Convert.ToBoolean(row["IsRead"]),
                            NotificationBody = row["NotificationBody"].ToString(),
                            NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                            NotificationType = Convert.ToInt32(row["NotificationType"])
                        };
                    }).ToList();

                    SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), creator.DeviceID);
                }
            }
            /**************************/

            JavaScriptSerializer js = new JavaScriptSerializer();
            Models.Attachment[] att = js.Deserialize<Models.Attachment[]>(js.Serialize(comment.Attachments));

            ComboMsgAttachment attachment = new ComboMsgAttachment();
            foreach (Models.Attachment item in att)
            {
                attachment.AddNew();
                attachment.AttachmentID = item.AttachmentID;
                attachment.ComboMsgID = newComment.ComboMsgID;

            }
            attachment.Save();

            comment.ComboCommentID = newComment.ComboCommentID;
            comment.CommentDate = newComment.CommentDate.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            _response.Entity = new Models.ComboComment[] { comment };

            SetContentResult(_response);
            return;
        }
Ejemplo n.º 29
0
        public void DeleteMsg(int id)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboMsg msg = new ComboMsg();
            msg.LoadByPrimaryKey(id);
            msg.IsDeleted = true;
            msg.Save();
            _response.Entity = null;
            SetContentResult(_response);
        }
Ejemplo n.º 30
0
        public void ToggleBanFriend(int userId, int FriendId, bool IsBanned)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ComboUserFriend friend = new ComboUserFriend();
            if (friend.LoadByPrimaryKey(userId, FriendId))
            {
                friend.IsBanned = IsBanned;
                friend.Save();
            }

            _response.Entity = null;
            SetContentResult(_response);
        }