Beispiel #1
0
        public ActionResult ChangeUser(FormCollection frmCollection, string submitButton)
        {
            int          ID        = Convert.ToInt32(frmCollection["UsrID"]);
            User         usr       = new User();
            UsersHandler usrHandlr = new UsersHandler();

            usr = usrHandlr.GetUserDetails(ID);
            if (submitButton == "Save")
            {
                string pwd   = frmCollection["pwdVal"];
                string email = frmCollection["Email"];
                if (!(string.IsNullOrEmpty(pwd)))
                {
                    pwd = Encryptor.MD5Hash(pwd);
                }
                if (!(string.IsNullOrEmpty(pwd)))
                {
                    usr.Password = pwd;
                }
                usr.Email = email;
                usrHandlr.UpdateUser(usr);
                return(RedirectToAction("Home", "UserHome", usr));
            }
            else if (submitButton == "Exit from Application")
            {
                usrHandlr.RemoveUser(Convert.ToInt32(frmCollection["UsrID"]));
                return(RedirectToAction("Login", "TCLogin"));
            }
            return(RedirectToAction("Home", "UserHome", usr));
        }
Beispiel #2
0
 public ActionResult Follow(UserSearch usrSrch)
 {
     try
     {
         UserHomeModel um               = new UserHomeModel();
         UsersHandler  usrHandlr        = new UsersHandler();
         IEnumerable <UserFollowing> uf = null;
         uf = usrHandlr.GetFollowingList(usrSrch.sourceUsrID);
         foreach (var usrFollow in uf)
         {
             if (usrFollow.FollowingUser_ID == usrSrch.ID)
             {
                 throw new Exception("You are already following this user");
             }
         }
         if (usrHandlr.FollowUser(usrSrch.sourceUsrID, usrSrch.ID))
         {
             User usr = new User();
             usr = usrHandlr.GetUserDetails(usrSrch.sourceUsrID);
             return(RedirectToAction("Home", "UserHome", usr));
         }
         return(Redirect(Request.UrlReferrer.ToString()));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
         return(Redirect(Request.UrlReferrer.ToString()));
     }
 }
Beispiel #3
0
        public ActionResult MoveToHome(UserSearch usrSearch)
        {
            UsersHandler usrHandlr = new UsersHandler();
            User         usr       = new User();

            usr = usrHandlr.GetUserDetails(usrSearch.sourceUsrID);
            return(RedirectToAction("Home", "UserHome", usr));
        }
        public ActionResult FollowerPage(int ID)
        {
            UserHomeModel um        = new UserHomeModel();
            UsersHandler  usrHandlr = new UsersHandler();

            um.user          = usrHandlr.GetUserDetails(ID);
            um.FollowersList = usrHandlr.GetFollowersList(ID);
            um.FollowingList = usrHandlr.GetFollowingList(ID);
            return(View(um));
        }
 public ActionResult UserHomeOperations(System.Web.Mvc.FormCollection frmCollection, string submitButton)
 {
     try
     {
         int          ID = 0;
         string       tweetMsg;
         string       errmsg    = "";
         TweetHandler twtHandlr = new TweetHandler();
         if (submitButton == "share")
         {
             ID       = Convert.ToInt32(frmCollection["UsrID"]);
             tweetMsg = frmCollection["msgTweet"];
             if (ID != 0)
             {
                 twtHandlr.PostTweet(ID, tweetMsg);
             }
             else
             {
                 errmsg = "Could not read user properly";
             }
         }
         else if (submitButton.Contains("Save"))
         {
             ID       = Convert.ToInt32(frmCollection["TweetID"].Split(',')[0]);
             tweetMsg = frmCollection["msgEdtTweet"];
             if (ID != 0)
             {
                 twtHandlr.UpdateTweet(ID, tweetMsg);
             }
             else
             {
                 errmsg = "Could not read tweet properly";
             }
         }
         else if (submitButton == "Delete")
         {
             ID = Convert.ToInt32(frmCollection["TweetID"].Split(',')[0]);
             if (ID != 0)
             {
                 twtHandlr.DeleteTweet(ID);
             }
             else
             {
                 errmsg = "Could not read tweet properly";
             }
         }
         else if (submitButton == "Cancel")
         {
             Redirect(Request.UrlReferrer.ToString());
         }
         else if (submitButton == "Search")
         {
             if (string.IsNullOrEmpty(frmCollection["txtSearch"]))
             {
                 throw new Exception("Search criteria cannot by empty");
             }
             else
             {
                 UserSearch   srchUser  = new UserSearch();
                 UsersHandler usrHandlr = new UsersHandler();
                 srchUser = usrHandlr.GetUserDetails(frmCollection["txtSearch"]);
                 if (srchUser != null)
                 {
                     srchUser.sourceUsrID = Convert.ToInt32(frmCollection["UsrID"]);
                     //SearchPage(srchUser);
                     return(RedirectToAction("SearchPage", "Search", srchUser));
                 }
             }
         }
         return(Redirect(Request.UrlReferrer.ToString()));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
         return(Redirect(Request.UrlReferrer.ToString()));
     }
 }