public IHttpActionResult UpdateContactInfo(ContactInformationUpdateRequest form) { if (string.IsNullOrEmpty(UserContext.User?.Username)) { return(Ok(new { success = false, reasons = new string[] { NullUserKey } })); } var result = AccountInfo.UpdateContactInfo( UserContext.User, form.FirstName, form.LastName, form.MiddleInitial, form.NameSuffix, form.Salutation, form.BillCountry, form.BillAddress1, form.BillAddress2, form.BillCity, form.BillPostalCode, form.BillState, form.ShipCountry, form.ShipAddress1, form.ShipAddress2, form.ShipCity, form.ShipPostalCode, form.ShipState, form.Fax, form.CountryCode, form.PhoneExtension, form.Phone, form.PhoneType, form.Company, form.JobFunction, form.JobIndustry, form.JobTitle); if (result.Success) { ProfileContext.Clear(); } return(Ok(new { success = result.Success, reasons = new string[] { GetContactResultKey(result) } })); }
public IHttpActionResult RegisterFreeTrial(RegisterFreeTrialRequest form) { if (IsExistingUser(form.Username)) { return(CreateUserExistsResponse()); } var newUser = NewUserFactory.Create(); newUser.FirstName = form.FirstName; newUser.LastName = form.LastName; newUser.Password = form.Password; newUser.Username = form.Username; var registerResult = RegisterUser.Register(newUser); if (!registerResult.Success) { return(Ok(new { success = false, reasons = registerResult.Errors.Select(GetRegisterValidationReason).ToList(), })); } var userContext = System.Web.Mvc.DependencyResolver.Current.GetService(typeof(IAuthenticatedUserContext)) as IAuthenticatedUserContext; if (!userContext.IsAuthenticated) { return(Ok(new { success = false, reasons = "LoginFailed" })); } var updateResult = AccountInfo.UpdateContactInfo( userContext.User, form.FirstName, form.LastName, string.Empty, string.Empty, string.Empty, form.Country, form.Address1, form.Address2, form.City, form.PostalCode, form.State, form.Country, form.Address1, form.Address2, form.City, form.PostalCode, form.State, string.Empty, string.Empty, string.Empty, form.Phone, string.Empty, form.Company, string.Empty, string.Empty, form.JobTitle); if (!updateResult.Success) { return(Ok(new { success = false, reasons = "AccountUpdatedFailed" })); } var userSubsContext = System.Web.Mvc.DependencyResolver.Current.GetService(typeof(IUserSubscriptionsContext)) as IUserSubscriptionsContext; var orderResult = UserOrder.CreateUserOrder(userContext.User, userSubsContext.Subscriptions); if (!orderResult.Success) { return(Ok(new { success = false, reasons = "CreateOrderFailed" })); } return(Ok(new { success = true, reasons = string.Empty, registration_type = "Free Trial" })); }