public ActionResult adduser(HttpPostedFileBase loginpicture, User user)
        {
            //Captcha Validation:
            if (user.Capthca.ToLower() != Session["Crntcapthca"].ToString().ToLower())
            {
                ModelState.AddModelError("", "Captcha Validation Failuer");
                user.Capthca = "";
                return View(user);
            }
            user.imageFileName = loginpicture;

            ConnectedUser connectedUser = null;
            int userNumber = UserManipulations.addUser(user, out connectedUser);
            if (userNumber > 0)
            {
                connectedUser.sessionStartedTime = DateTime.Now.ToLocalTime().ToString();
                Session["userdata"] = connectedUser;
                FormsAuthentication.SetAuthCookie(userNumber.ToString(), true);
                return RedirectToAction("index", "myprtctd");
            }
            else if (userNumber == 0)
            {
             ModelState.AddModelError("userLogin", "this login Already Exist");
            }
            else
            {
             ModelState.AddModelError("", "problem during trying to reach the DB");
            }
               return View(user);
        }
 //------------------------------------------------------------------------------------------//
 //Edit User Page:
 public ActionResult EditUser()
 {
     User tempUser = new User();
     tempUser.email = ((ConnectedUser)Session["userdate"]).getUserEmail;
     tempUser.realname = ((ConnectedUser)Session["userdate"]).realName;
     return View(tempUser);
 }
        public ActionResult EditUser(HttpPostedFileBase loginpicture, User user)
        {
            String sessionTimeOut = ((ConnectedUser)Session["userdata"]).sessionStartedTime;
            user.imageFileName = loginpicture;

            ConnectedUser connectedUser = null;
            int userNumber = UserManipulations.editUser(user, out connectedUser);
            if (userNumber > 0)
            {
                connectedUser.sessionStartedTime = sessionTimeOut;
                Session["userdata"] = connectedUser;
                //FormsAuthentication.SetAuthCookie(userNumber.ToString(), true);
                return RedirectToAction("index", "myprtctd");
            }
            else if (userNumber == 0)
            {
             ModelState.AddModelError("userLogin", "this login Already Exist");
            }
            else
            {
             ModelState.AddModelError("", "Failed to update given user.");
            }
               return View(user);
        }
        public ActionResult Login(User givenUser)
        {
            string captchaString = Session["Crntcapthca"].ToString().ToLower();

            if (givenUser.Capthca.ToLower() != captchaString)
            {
                ModelState.AddModelError("", "Captcha Validation Failuer");
                givenUser.Capthca = "";
                return View(givenUser);
            }

            else{
                ConnectedUser connectedUser = null;
                if (UserManipulations.ifUserExists(givenUser.email, givenUser.password, out connectedUser) > 0)
                {
                    connectedUser.sessionStartedTime = DateTime.Now.ToLocalTime().ToString();
                    Session["userdata"] = connectedUser;
                    FormsAuthentication.SetAuthCookie(givenUser.email, true);
                    return RedirectToAction("index", "myprtctd");
                }
                ModelState.AddModelError("", "Invalide Username or Password");
            }
            return View(givenUser);
        }