public void SetLoginSession(UserModel userModel)
 {
     Session["IsLoggedIn"] = true;
     Session["UserId"] = userModel.Id;
     Response.Cookies.Add(new HttpCookie("UserId", userModel.Id.ToString()));
     Response.Cookies.Add(new HttpCookie("Username", userModel.FirstName + " " + userModel.LastName));
 }
 public void SetLoginSession(UserModel user)
 {
     Session["IsLoggedIn"] = true;
     Session["userId"] = user.MLoginID;
     Response.Cookies.Add(new HttpCookie("Baby_userid", user.MLoginRightsUserID.ToString()));
     Response.Cookies.Add(new HttpCookie("Baby_username", user.MLoginFirstName + " " + user.MLoginLastName));
 }
        public UserModel GetUserDetails(int userId)
        {
            UserRepository userRepository = new UserRepository();
            UserModel userModel = new UserModel();

            UserDTO userEntity = userRepository.GetUserDetails(userId);
            AutoMapper.Mapper.Map(userEntity, userModel);
            return userModel;
        }
        public UserModel ValidateUser(string userName, string password)
        {
            UserRepository userRepository = new UserRepository();
               UserModel userModel = new UserModel();

               UserDTO userEntity = userRepository.ValidateUser(userName, password);
               AutoMapper.Mapper.Map(userEntity, userModel);

               return userModel;
        }
        public ActionResult UserLogin(UserModel userModel)
        {
            UserManager userMgr = new UserManager();
            userModel = userMgr.ValidateUser(userModel.UserName, userModel.Password);

            if (userModel.Id > 0)
            {
                SetLoginSession(userModel);
                return RedirectToAction("CheckOut", new RouteValueDictionary(new { controller = "Shop", action = "CheckOut" }));
            }
            return RedirectToAction("Login", "Home");
        }
 public ActionResult UserLogin(UserModel user)
 {
     Session["Error"] = null;
     List<DataError> error = null;
     if (UserService.ValidateUser(user, out error))
     {
         SetLoginSession(user);
         ViewData["AddToCartItems"] = ShoppingCartService.CountShoppingCartItems(GetShoppingCartId());
         return RedirectToAction("CheckOut", new RouteValueDictionary(new { controller = "Shop", action = "CheckOut" }));
     }
     Session["Error"] = ToJSON(error);
     return RedirectToAction("Login", "Home");
 }
 public static UserModel ToLocal(this UserDTO user)
 {
     if (user != null)
        {
        UserModel toReturn = new UserModel();
        //toReturn.MLoginID = user.MLoginID;
        //toReturn.MLoginFirstName = user.MLoginFirstName;
        //toReturn.MLoginLastName = user.MLoginLastName;
        //toReturn.MLoginAddress = user.MLoginAddress;
        //toReturn.MLoginState = user.MLoginState;
        //toReturn.MLoginCountry = user.MLoginCountry;
        //toReturn.MLoginCity = user.MLoginCity;
        //toReturn.MLoginZip = user.MLoginZip;
        return toReturn;
        }
        return null;
 }
        public static bool CreateUser(UserModel user)
        {
            UserManager userMgr = new UserManager();
            bool status = false;

            UserDTO toReturn = new UserDTO();
            //toReturn.MLoginID = user.MLoginID;
            //toReturn.MLoginFirstName = user.MLoginFirstName;
            //toReturn.MLoginLastName = user.MLoginLastName;
            //toReturn.MLoginAddress = user.MLoginAddress;
            //toReturn.MLoginState = user.MLoginState;
            //toReturn.MLoginCountry = user.MLoginCountry;
            //toReturn.MLoginCity = user.MLoginCity;
            //toReturn.MLoginZip = user.MLoginZip;

            status = userMgr.CreateUser(toReturn);
            return status;
        }
        public static UserModel GetUserDetails(int userId)
        {
            UserDTO user = new UserDTO();
            UserManager userMgr = new UserManager();

            //user = userMgr.GetUserDetails(userId);
            UserModel toReturn = new UserModel();

            if (user != null)
            {
                //toReturn.MLoginID = user.MLoginID;
                //toReturn.MLoginFirstName = user.MLoginFirstName;
                //toReturn.MLoginLastName = user.MLoginLastName;
                //toReturn.MLoginAddress = user.MLoginAddress;
                //toReturn.MLoginState = user.MLoginState;
                //toReturn.MLoginCountry = user.MLoginCountry;
                //toReturn.MLoginCity = user.MLoginCity;
                //toReturn.MLoginZip = user.MLoginZip;
            }

            return toReturn;
        }
 public static bool ValidateUser(UserModel user, out List<DataError> dataError)
 {
     bool IsValidate = false;
     dataError = null;
     UserDTO userDetail = new UserDTO();
     if (user.Validate(UseralidationType.LoginUser, out dataError))
     {
         UserManager userMgr = new UserManager();
         //userDetail = userMgr.ValidateUser(new UserDTO { MLoginRightsUserID = user.MLoginRightsUserID, MLoginRightsPassword = user.MLoginRightsPassword });
         userDetail = null;
         //if (userDetail != null)
         //{
         //    user.MLoginID = userDetail.MLoginID;
         //    IsValidate = true;
         //}
         //else
         //{
         //    IsValidate = false;
         //    dataError.Add(new DataError() { PropertyName = "Message", ErrorDescription = ErrorMessages.User.InValidCredential });
         //}
         return IsValidate;
     }
     return IsValidate;
 }
 public JsonResult CreateUser(UserModel user)
 {
     return Json(UserService.CreateUser(user), JsonRequestBehavior.AllowGet);
 }
 public ActionResult Register(UserModel user)
 {
     return View();
 }
 public ActionResult Login(UserModel user)
 {
     return View();
 }