public void Save(FacebookShopSiteSettingsViewModel viewModel) { ApiBaseUrl = viewModel.ApiBaseUrl; DefaultJsonForProductUpdate = viewModel.DefaultJsonForProductUpdate; BusinessId = viewModel.BusinessId; CatalogId = viewModel.CatalogId; //AppId = viewModel.AppId; //AppSecret = viewModel.AppSecret; AccessToken = viewModel.AccessToken; }
private bool Validate(FacebookShopSiteSettingsViewModel viewModel, FacebookShopSiteSettingsPart part, IUpdateModel updater) { if (string.IsNullOrWhiteSpace(viewModel.ApiBaseUrl)) { updater.AddModelError(Prefix, T("Api base url is required.")); return(false); } //if (string.IsNullOrWhiteSpace(viewModel.AppId)) { // updater.AddModelError(Prefix, T("App Id is required.")); // return false; //} //if (string.IsNullOrWhiteSpace(viewModel.AppSecret)) { // updater.AddModelError(Prefix, T("App Secret is required.")); // return false; //} var serviceContext = FacebookShopServiceContext.From(viewModel); if (string.IsNullOrWhiteSpace(viewModel.BusinessId)) { updater.AddModelError(Prefix, T("Invalid business id.")); return(false); } if (string.IsNullOrWhiteSpace(viewModel.CatalogId)) { updater.AddModelError(Prefix, T("Invalid catalog id.")); return(false); } if (string.IsNullOrWhiteSpace(viewModel.AccessToken)) { updater.AddModelError(Prefix, T("Invalid access token.")); return(false); } if (!_facebookShopService.CheckBusiness(serviceContext)) { updater.AddModelError(Prefix, T("Business check failed. Check you're using the right business id and a valid access token.")); return(false); } if (!_facebookShopService.CheckCatalog(serviceContext)) { updater.AddModelError(Prefix, T("Catalog check failed. Check you're using the right catalog id and a valid access token.")); return(false); } return(true); }
public static FacebookShopServiceContext From(FacebookShopSiteSettingsViewModel viewModel) { return(new FacebookShopServiceContext() { ApiBaseUrl = viewModel.ApiBaseUrl, DefaultJsonForProductUpdate = viewModel.DefaultJsonForProductUpdate, BusinessId = viewModel.BusinessId, CatalogId = viewModel.CatalogId, //AppId = viewModel.AppId, //AppSecret = viewModel.AppSecret, AccessToken = viewModel.AccessToken }); }