Example #1
0
        public ActionResult SignUp(CustomerModels model)
        {
            try
            {
                if (!string.IsNullOrEmpty(model.Password) && !string.IsNullOrEmpty(model.ConfirmPassword) && !model.Password.Equals(model.ConfirmPassword))
                {
                    ModelState.AddModelError("ConfirmPassword", "Xác nhận mật khẩu không chính xác !");
                }

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                model.Password = CommonHelper.Encrypt(model.Password);
                string msg    = "";
                string cusId  = "";
                var    result = _factory.CreateOrUpdate(model, ref cusId, ref msg);
                if (result)
                {
                    var         data        = _factory.GetDetail(cusId);
                    UserSession userSession = new UserSession();
                    userSession.Email     = data.Email;
                    userSession.UserName  = data.FirstName + " " + data.LastName;
                    userSession.FirstName = data.FirstName;
                    userSession.LastName  = data.LastName;
                    userSession.Phone     = data.Phone;
                    userSession.Address   = data.Address;
                    userSession.UserId    = data.ID;
                    userSession.PostCode  = data.Postcode;
                    userSession.Country   = data.Country;
                    userSession.City      = data.City;
                    Session.Add("UserClient", userSession);
                    string     myObjectJson = JsonConvert.SerializeObject(userSession); //new JavaScriptSerializer().Serialize(userSession);
                    HttpCookie cookie       = new HttpCookie("UserClientCookie");
                    cookie.Expires = DateTime.Now.AddMonths(1);
                    cookie.Value   = Server.UrlEncode(myObjectJson);
                    HttpContext.Response.Cookies.Add(cookie);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("Email", msg);
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                NSLog.Logger.Error("SignUp", ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }
        public CustomerModels GetDetail(string Id)
        {
            var data = _factory.GetDetail(Id);

            if (data != null)
            {
                data.Password        = CommonHelper.Decrypt(data.Password);
                data.ConfirmPassword = data.Password;
            }
            return(data);
        }
Example #3
0
 public BasesController()
 {
     facC = new CMSCustomersFactory();
     try
     {
         if (CurrentUser != null && CurrentUser.UserId != null)
         {
             var data = facC.GetDetail(CurrentUser.UserId);
             CurrentUser.TotalCredits = data != null ? data.TotalCredit : 0;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public CustomerModels GetDetail(string Id)
        {
            var data = _factory.GetDetail(Id);

            return(data);
        }