public ActionResult UpdateAddresses(int?[] country, string[] states_canadian, string[] states_other, string[] states_us, string billing_first_name, string billing_last_name, string billing_company, string billing_address, string billing_city, long?billing_citySelected, string billing_postcode, string billing_phone, string shipping_first_name, string shipping_last_name, string shipping_company, string shipping_address, string shipping_city, long?shipping_citySelected, string shipping_postcode, string shipping_phone) { var ownerid = sessionid.Value; var profile = repository.GetUserById(ownerid, subdomainid.Value); if (profile == null) { return(SendJsonErrorResponse("Cannot find profile")); } var addressHandler = new AddressHandler(profile.organisation1, repository); addressHandler.SetShippingAndBillingAddresses(billing_first_name, billing_last_name, billing_company, billing_address, billing_city, billing_citySelected, billing_postcode, billing_phone, country.ElementAtOrDefault(0), states_canadian.ElementAtOrDefault(0), states_other.ElementAtOrDefault(0), states_us.ElementAtOrDefault(0), shipping_first_name, shipping_last_name, shipping_company, shipping_address, shipping_city, shipping_citySelected, shipping_postcode, shipping_phone, country.ElementAtOrDefault(1), states_canadian.ElementAtOrDefault(1), states_other.ElementAtOrDefault(1), states_us.ElementAtOrDefault(1), false); repository.Save(); CacheHelper.Instance.invalidate_dependency(DependencyType.products_subdomain, subdomainid.Value.ToString()); CacheHelper.Instance.invalidate_dependency(DependencyType.organisation, subdomainid.Value.ToString()); #if LUCENE // update index var indexer = new LuceneWorker(db, profile.organisation1.MASTERsubdomain.ToIdName()); indexer.AddToIndex(LuceneIndexType.CONTACTS, profile); #endif return(Json(OPERATION_SUCCESSFUL.ToJsonOKData())); }
public ActionResult Settings(decimal?[] shipping_cost, int?[] shipping_destination, long?shippingProfileID, ShippingProfileType shippingType) { if (shippingProfileID.HasValue) { // delete existing rules in profile if (shippingType == ShippingProfileType.FLATRATE) { ShippingProfile.UpdateFlatrateShipping(shippingProfileID.Value, shipping_cost, shipping_destination, subdomainid.Value); } } return(Json(OPERATION_SUCCESSFUL.ToJsonOKData())); }
public ActionResult Settings(bool storeEnabled, string motd, string storeName, string facebookCoupon) { MASTERdomain.organisation.motd = motd; MASTERdomain.storeName = storeName; // website verificaiton bool verifySite = false; Webmaster webmaster = null; SitesEntry site = null; // store if (storeEnabled) { // check that payment methods have been configured var paymentmethods = new PaymentMethodList(); paymentmethods.Initialise(MASTERdomain, false); if (paymentmethods.count == 0) { return(Json("You need to specify your paypal id and/or a payment method before you can enable your store. <a href='/dashboard/account#account_payment'>Setup payment methods</a>".ToJsonFail())); } // don't allow store to be enabled if (MASTERdomain.trialExpired) { return(Json("Store cannot be made public. Your trial period has expired.".ToJsonFail())); } // only register the following with google if store not already enabled if (!IsStoreEnabled) { MASTERdomain.flags |= (int)SubdomainFlags.STORE_ENABLED; #if !DEBUG // update info to google webmaster webmaster = new Webmaster(); var url = accountHostname.ToDomainUrl("", true); site = webmaster.AddSite(url); if (site != null) { var metaTag = site.VerificationMethod.Value; MASTERdomain.metaTagVerification = metaTag; verifySite = true; } #endif } } else { MASTERdomain.flags &= ~(int)SubdomainFlags.STORE_ENABLED; } // handle facebook coupon if (!string.IsNullOrEmpty(facebookCoupon)) { var coupon = repository.GetCoupons(subdomainid.Value).SingleOrDefault(x => x.code == facebookCoupon && !x.expired); if (coupon != null) { MASTERdomain.facebookCoupon = coupon.id; } } else { MASTERdomain.facebookCoupon = null; } repository.Save(); // SUBMIT // need to be done here so that metatag is saved and then can be shown at store page if (verifySite) { var url = accountHostname.ToDomainUrl("", true); // verify site webmaster.VerifySite(url, site); // add sitemap new Thread(() => { var sitemap = string.Concat(url, "google/sitemap"); webmaster.AddSitemap(url, sitemap); }).Start(); } CacheHelper.Instance.invalidate_dependency(DependencyType.organisation, subdomainid.Value.ToString()); return(Json(OPERATION_SUCCESSFUL.ToJsonOKData())); }
public ActionResult UpdateProfile(string address, string city, string citySelected, string coPhone, string companyName, int?country, string fax, string firstName, string gender, string lastName, string notes, string phone, string postcode, string title, string currency, string timezone, string email, string states_canadian, string states_other, string states_us) { var ownerid = sessionid.Value; try { var profile = repository.GetUserById(ownerid, subdomainid.Value); if (profile == null) { return(SendJsonErrorResponse("Cannot find profile")); } // no need to take into account whether an organisation is there because it will always be created profile.organisation1.address = address; if (!string.IsNullOrEmpty(citySelected)) { profile.organisation1.city = int.Parse(citySelected); } else if (!string.IsNullOrEmpty(city)) { profile.organisation1.city = repository.AddCity(city).id; } profile.organisation1.phone = coPhone; profile.organisation1.name = companyName; profile.organisation1.fax = fax; if (country != null) { profile.organisation1.country = country; profile.organisation1.state = AddressHandler.GetState(country, states_us, states_canadian, states_other); } profile.firstName = firstName; profile.gender = gender; profile.lastName = lastName; profile.notes = notes; profile.phoneNumber = phone; profile.organisation1.postcode = postcode; profile.title = title; if (!string.IsNullOrEmpty(email) && email != profile.email) { profile.email = email.Trim(); var password = Crypto.Utility.GetRandomString(); // save password hash var hash = Crypto.Utility.ComputePasswordHash(email + password); profile.passwordHash = hash; // set flag profile.settings |= (int)UserSettings.PASSWORD_RESET; // email new password to user var data = new ViewDataDictionary() { { "password", password } }; EmailHelper.SendEmail(EmailViewType.ACCOUNT_PASSWORD_RESET, data, "Password Reset", email, profile.ToFullName(), null); } if (permission.HasFlag(UserPermission.NETWORK_SETTINGS)) { if (!string.IsNullOrEmpty(timezone)) { profile.timezone = timezone; } if (!string.IsNullOrEmpty(currency)) { profile.organisation1.MASTERsubdomain.currency = int.Parse(currency); } } repository.Save(); CacheHelper.Instance.invalidate_dependency(DependencyType.products_subdomain, subdomainid.Value.ToString()); CacheHelper.Instance.invalidate_dependency(DependencyType.organisation, subdomainid.Value.ToString()); #if LUCENE // update index var indexer = new LuceneWorker(db, profile.organisation1.MASTERsubdomain.ToIdName()); indexer.AddToIndex(LuceneIndexType.CONTACTS, profile); #endif } catch (Exception ex) { return(SendJsonErrorResponse(ex)); } // will be intepreted as an error if Content() is used return(Json(OPERATION_SUCCESSFUL.ToJsonOKData())); }