Пример #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var acct = new WFSUser();
                acct.FirstName = model.FirstName;
                acct.LastName = model.LastName;
                acct.Password = model.Password;
                acct.UserType = WFSUserTypeEnum.Customer;
                acct.EmailAddress = model.Email;
                acct.BillingAddress = new PhoneAddress()
                {
                    Address1 = model.AddressInfo.Address1,
                    Address2 = model.AddressInfo.Address2,
                    City = model.AddressInfo.City,
                    State = model.AddressInfo.State,
                    ZipCode = model.AddressInfo.ZipCode,
                    PhoneNumber = model.AddressInfo.PhoneNumber,
                    PhoneExt = model.AddressInfo.PhoneExt,
                };

                var resp = _wfsUSerManager.SaveCustomer(new SaveWFSUserRequest() { UserInfo = acct });

                if (resp.Status == Status.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.Email, createPersistentCookie: false);

                    AddAuthCookie(resp.UserInfo.UserId, resp.UserInfo.MembershipGuid);

                    var uiresponse = new UIResponse<Guid>();
                    return Json(uiresponse);
                }
                else
                {
                    var uiresponse = new UIResponse<RegisterModel>();

                    model.Merge(resp);
                    uiresponse.Status = resp.Status;
                    uiresponse.Subject = model;
                    uiresponse.HtmlResult = RenderPartialViewToString("Register", model);

                    return Json(uiresponse);
                }
            }

            return View(model);
        }