示例#1
0
    public void FaceBookLogin()
    {
        GetMethods.GetUserId(email, (id) => {
            if (id != "0")             // The user exits in the data base

            // Verify if an Update is necessary.
            {
                UpdateMethods.UpdateUsersDatabase(id, userName, age, AppManeger.instance.userGender.ToString(), (result) => {
                    Debug.Log(string.Format("Update {0}", result));
                });

                string fileName = string.Format("Prefs_{0}", AppManeger.instance.userID);

                //GetMethods.GetUserPrefs(id, (prefsResult) => {PrefsResult(prefsResult);}); // Check if the user are in the Prefs Database

                if (SaveLoadData.FileExits(fileName))                 // If exit

                {
                    SaveLoadData.Load(fileName, SaveLoadData.DataType.UserPrefs); // load from device
                    GoToCheersPanel();                                            // Means the user has everyting setted;
                }
                else
                {
                    GetMethods.GetUserPrefs(id, (prefsResult) => { PrefsResult(prefsResult); });                   // Check if the user are in the Prefs Database
                }
            }
            else                // User don't exit in the data base

            {
                PostMethods.InsertUserIntoUsersDatabase(userName, age, email, gender, (result) => {
                    InsertUserResult(result);
                });
            }
        });
    }
示例#2
0
        public ActionResult UserDeleteComment(int postId, int commentId)
        {
            string username = User.Identity.Name;
            var    userId   = GetMethods.GetUserId(username);

            if (CheckMethods.IsUsersComment(userId, commentId))
            {
                DeleteComment(commentId);
                return(RedirectToAction("ShowPost", "MainPage", new { postId = postId }));
            }
            return(RedirectToAction("AccessDenied", "Error"));
        }
示例#3
0
    void InsertUserResult(string result)
    {
        if (result == "Success" || result == "success")          // Finish to insert user into data base

        {
            Debug.Log(string.Format("Users was {0} insert into users database", result));
            GetMethods.GetUserId(email, (id) => {
                if (id != "0")                  // The user exits in the data base

                {
                    AppManeger.instance.userID = id;
                    GetMethods.GetUserPrefs(id, (prefsResult) => {
                        PrefsResult(prefsResult);
                    });                     // Check if the user are in the Prefs Database
                }
            });
        }
        else
        {
            Debug.Log(result);
        }
    }
示例#4
0
        public ActionResult UserUpdateComment(int postId, int commentId)
        {
            using (BlogDbContext db = new BlogDbContext())
            {
                string username = User.Identity.Name;
                var    userId   = GetMethods.GetUserId(username);
                if (!CheckMethods.IsUsersComment(userId, commentId))
                {
                    return(RedirectToAction("AccessDenied", "Error"));
                }
                string commentToUpdate = db.Comments.Where(c => c.CommentId == commentId).Select(c => c.Content).FirstOrDefault();
                ViewBag.CommentToUpdate = commentToUpdate;
                var post     = db.Posts.FirstOrDefault(p => p.PostId == postId);
                var user     = db.Users.FirstOrDefault(u => u.UserId == post.UserId);
                var comments = db.Comments.Where(c => c.PostId == postId).ToList();
                comments     = GetMethods.GetInitializedUserList(comments);
                ViewBag.User = user;

                ViewBag.Comments   = comments;
                ViewData["Layout"] = GetMethods.GetLayout(User.Identity.Name);
                return(View("~/Views/Main/ShowPost.cshtml", post));
            }
        }