当前位置: 首页>>代码示例>>C#>>正文


C# CurrencyModel类代码示例

本文整理汇总了C#中CurrencyModel的典型用法代码示例。如果您正苦于以下问题:C# CurrencyModel类的具体用法?C# CurrencyModel怎么用?C# CurrencyModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CurrencyModel类属于命名空间,在下文中一共展示了CurrencyModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateLocales

 protected void UpdateLocales(Currency currency, CurrencyModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(currency,
                                                        x => x.Name,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
开发者ID:haithemChkel,项目名称:nopCommerce_33,代码行数:10,代码来源:CurrencyController.cs

示例2: Create

        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
                return AccessDeniedView();

            var model = new CurrencyModel();
            //locales
            AddLocales(_languageService, model.Locales);
            //default values
            model.Published = true;
            model.Rate = 1;
            return View(model);
        }
开发者ID:btolbert,项目名称:test-commerce,代码行数:13,代码来源:CurrencyController.cs

示例3: PrepareStoresMappingModel

        protected virtual void PrepareStoresMappingModel(CurrencyModel model, Currency currency, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            model.AvailableStores = _storeService
                .GetAllStores()
                .Select(s => s.ToModel())
                .ToList();
            if (!excludeProperties)
            {
                if (currency != null)
                {
                    model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(currency);
                }
            }
        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:17,代码来源:CurrencyController.cs

示例4: PrepareStoresMappingModel

        protected virtual void PrepareStoresMappingModel(CurrencyModel model, Currency currency, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (!excludeProperties && currency != null)
                model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(currency).ToList();

            var allStores = _storeService.GetAllStores();
            foreach (var store in allStores)
            {
                model.AvailableStores.Add(new SelectListItem
                {
                    Text = store.Name,
                    Value = store.Id.ToString(),
                    Selected = model.SelectedStoreIds.Contains(store.Id)
                });
            }
        }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:19,代码来源:CurrencyController.cs

示例5: Edit

        public ActionResult Edit(CurrencyModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
                return AccessDeniedView();

            var currency = _currencyService.GetCurrencyById(model.Id);
            if (currency == null)
                //No currency found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                currency = model.ToEntity(currency);
                currency.UpdatedOnUtc = DateTime.UtcNow;
                _currencyService.UpdateCurrency(currency);
                //locales
                UpdateLocales(currency, model);
                //Stores
                SaveStoreMappings(currency, model);

                SuccessNotification(_localizationService.GetResource("Admin.Configuration.Currencies.Updated"));
                return continueEditing ? RedirectToAction("Edit", new { id = currency.Id }) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            model.CreatedOn = _dateTimeHelper.ConvertToUserTime(currency.CreatedOnUtc, DateTimeKind.Utc);

            //Stores
            PrepareStoresMappingModel(model, currency, true);

            return View(model);
        }
开发者ID:nguyentu1982,项目名称:quancu,代码行数:32,代码来源:CurrencyController.cs

示例6: Edit

        public ActionResult Edit(CurrencyModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
                return AccessDeniedView();

            var currency = _currencyService.GetCurrencyById(model.Id);
            if (currency == null)
                //No currency found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                //ensure we have at least one published language
                var allCurrencies = _currencyService.GetAllCurrencies();
                if (allCurrencies.Count == 1 && allCurrencies[0].Id == currency.Id &&
                    !model.Published)
                {
                    ErrorNotification("At least one published currency is required.");
                    return RedirectToAction("Edit", new { id = currency.Id });
                }

                currency = model.ToEntity(currency);
                currency.UpdatedOnUtc = DateTime.UtcNow;
                _currencyService.UpdateCurrency(currency);
                //locales
                UpdateLocales(currency, model);
                //Stores
                SaveStoreMappings(currency, model);

                SuccessNotification(_localizationService.GetResource("Admin.Configuration.Currencies.Updated"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return RedirectToAction("Edit", new {id = currency.Id});
                }
                return RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            model.CreatedOn = _dateTimeHelper.ConvertToUserTime(currency.CreatedOnUtc, DateTimeKind.Utc);

            //Stores
            PrepareStoresMappingModel(model, currency, true);

            return View(model);
        }
开发者ID:Rustemt,项目名称:Nopcommerce-with-Couchbase,代码行数:49,代码来源:CurrencyController.cs

示例7: CurrencySelector

        public ActionResult CurrencySelector()
        {
            var availableCurrencies = _cacheManager.Get(string.Format(ModelCacheEventConsumer.AVAILABLE_CURRENCIES_MODEL_KEY, _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id), () =>
            {
                var result = _currencyService
                    .GetAllCurrencies(storeId: _storeContext.CurrentStore.Id)
                    .Select(x =>
                    {
                        //currency char
                        var currencySymbol = "";
                        if (!string.IsNullOrEmpty(x.DisplayLocale))
                            currencySymbol = new RegionInfo(x.DisplayLocale).CurrencySymbol;
                        else
                            currencySymbol = x.CurrencyCode;
                        //model
                        var currencyModel = new CurrencyModel
                        {
                            Id = x.Id,
                            Name = x.GetLocalized(y => y.Name),
                            CurrencySymbol = currencySymbol
                        };
                        return currencyModel;
                    })
                    .ToList();
                return result;
            });

            var model = new CurrencySelectorModel
            {
                CurrentCurrencyId = _workContext.WorkingCurrency.Id,
                AvailableCurrencies = availableCurrencies
            };

            if (model.AvailableCurrencies.Count == 1)
                Content("");

            return PartialView(model);
        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:38,代码来源:CommonController.cs

示例8: PrepareCurrencyModel

        private void PrepareCurrencyModel(CurrencyModel model, Currency currency, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            var allStores = _services.StoreService.GetAllStores();

            model.AvailableStores = allStores.Select(s => s.ToModel()).ToList();

            if (currency != null)
            {
                model.PrimaryStoreCurrencyStores = allStores
                    .Where(x => x.PrimaryStoreCurrencyId == currency.Id)
                    .Select(x => new SelectListItem
                    {
                        Text = x.Name,
                        Value = Url.Action("Edit", "Store", new { id = x.Id })
                    })
                    .ToList();

                model.PrimaryExchangeRateCurrencyStores = allStores
                    .Where(x => x.PrimaryExchangeRateCurrencyId == currency.Id)
                    .Select(x => new SelectListItem
                    {
                        Text = x.Name,
                        Value = Url.Action("Edit", "Store", new { id = x.Id })
                    })
                    .ToList();
            }

            if (!excludeProperties)
            {
                model.SelectedStoreIds = (currency == null ? new int[0] : _storeMappingService.GetStoresIdsWithAccess(currency));
            }
        }
开发者ID:toannguyen241994,项目名称:SmartStoreNET,代码行数:35,代码来源:CurrencyController.cs

示例9: Edit

        public ActionResult Edit(CurrencyModel model, bool continueEditing)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageCurrencies))
                return AccessDeniedView();

            var currency = _currencyService.GetCurrencyById(model.Id);
            if (currency == null)
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                currency = model.ToEntity(currency);

                if (!IsAttachedToStore(currency, _services.StoreService.GetAllStores(), false))
                {
                    currency.UpdatedOnUtc = DateTime.UtcNow;

                    _currencyService.UpdateCurrency(currency);

                    //locales
                    UpdateLocales(currency, model);

                    //Stores
                    _storeMappingService.SaveStoreMappings<Currency>(currency, model.SelectedStoreIds);

                    NotifySuccess(_services.Localization.GetResource("Admin.Configuration.Currencies.Updated"));
                    return continueEditing ? RedirectToAction("Edit", new { id = currency.Id }) : RedirectToAction("List");
                }
            }

            //If we got this far, something failed, redisplay form
            model.CreatedOn = _dateTimeHelper.ConvertToUserTime(currency.CreatedOnUtc, DateTimeKind.Utc);

            //Stores
            PrepareCurrencyModel(model, currency, true);

            return View(model);
        }
开发者ID:toannguyen241994,项目名称:SmartStoreNET,代码行数:38,代码来源:CurrencyController.cs

示例10: UpdateLocales

        protected virtual List<LocalizedProperty> UpdateLocales(Currency currency, CurrencyModel model)
        {
            List<LocalizedProperty> localized = new List<LocalizedProperty>();
            foreach (var local in model.Locales)
            {

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "Name",
                    LocaleValue = local.Name
                });
            }
            return localized;
        }
开发者ID:powareverb,项目名称:grandnode,代码行数:15,代码来源:CurrencyController.cs

示例11: CurrenciesModel

 /// <summary>
 /// Initializes a new instance of the <see cref="CurrenciesModel"/> class.
 /// </summary>
 /// <param name="selectedCurrency">The selected currency.</param>
 /// <param name="currencies">The currencies.</param>
 public CurrenciesModel(string selectedCurrency, CurrencyModel[] currencies)
 {
     SelectedCurrency = selectedCurrency;
     Currencies = currencies;
 }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:10,代码来源:CurrencyModel.cs

示例12: ApplicationClientModel

		public ApplicationClientModel()
		{
			Currency = new CurrencyModel();
		}
开发者ID:UHgEHEP,项目名称:test,代码行数:4,代码来源:ApplicationClientModel.cs

示例13: ApplicationAdminModel

		public ApplicationAdminModel()
		{
			Currency = new CurrencyModel();
		}
开发者ID:UHgEHEP,项目名称:test,代码行数:4,代码来源:ApplicationAdminModel.cs

示例14: ApplicationSenderModel

		public ApplicationSenderModel()
		{
			Currency = new CurrencyModel();
		}
开发者ID:UHgEHEP,项目名称:test,代码行数:4,代码来源:ApplicationSenderModel.cs

示例15: SaveStoreMappings

 protected void SaveStoreMappings(Currency currency, CurrencyModel model)
 {
     var existingStoreMappings = _storeMappingService.GetStoreMappings(currency);
     var allStores = _storeService.GetAllStores();
     foreach (var store in allStores)
     {
         if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
         {
             //new role
             if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0)
                 _storeMappingService.InsertStoreMapping(currency, store.Id);
         }
         else
         {
             //removed role
             var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id);
             if (storeMappingToDelete != null)
                 _storeMappingService.DeleteStoreMapping(storeMappingToDelete);
         }
     }
 }
开发者ID:nguyentu1982,项目名称:quancu,代码行数:21,代码来源:CurrencyController.cs


注:本文中的CurrencyModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。