예제 #1
0
        public IHttpActionResult GetCurrentStore(string fields = "")
        {
            Store store = _storeContext.CurrentStore;

            if (store == null)
            {
                return(Error(HttpStatusCode.NotFound, "store", "store not found"));
            }

            StoreDto storeDto = store.ToDto();

            Currency primaryCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);

            if (!String.IsNullOrEmpty(primaryCurrency.DisplayLocale))
            {
                storeDto.PrimaryCurrencyDisplayLocale = primaryCurrency.DisplayLocale;
            }

            var storesRootObject = new StoresRootObject();

            storesRootObject.Stores.Add(storeDto);

            var json = _jsonFieldsSerializer.Serialize(storesRootObject, fields);

            return(new RawJsonActionResult(json));
        }
        public async Task <IActionResult> GetCurrentStore(string fields = "")
        {
            var store = _storeContext.GetCurrentStore();

            if (store == null)
            {
                return(Error(HttpStatusCode.NotFound, "store", "store not found"));
            }

            var storeDto = await _dtoHelper.PrepareStoreDTOAsync(store);

            var storesRootObject = new StoresRootObject();

            storesRootObject.Stores.Add(storeDto);

            var json = JsonFieldsSerializer.Serialize(storesRootObject, fields);

            return(new RawJsonActionResult(json));
        }
예제 #3
0
        public IHttpActionResult GetCurrentStore(string fields = "")
        {
            Store store = _storeContext.CurrentStore;

            if (store == null)
            {
                return(Error(HttpStatusCode.NotFound, "store", "store not found"));
            }

            StoreDto storeDto = _dtoHelper.PrepareStoreDTO(store);

            var storesRootObject = new StoresRootObject();

            storesRootObject.Stores.Add(storeDto);

            var json = _jsonFieldsSerializer.Serialize(storesRootObject, fields);

            return(new RawJsonActionResult(json));
        }
        public async Task <IActionResult> GetAllStores(string fields = "")
        {
            var allStores = await StoreService.GetAllStoresAsync();

            IList <StoreDto> storesAsDto = new List <StoreDto>();

            foreach (var store in allStores)
            {
                var storeDto = await _dtoHelper.PrepareStoreDTOAsync(store);

                storesAsDto.Add(storeDto);
            }

            var storesRootObject = new StoresRootObject
            {
                Stores = storesAsDto
            };

            var json = JsonFieldsSerializer.Serialize(storesRootObject, fields);

            return(new RawJsonActionResult(json));
        }
예제 #5
0
        public IHttpActionResult GetAllStores(string fields = "")
        {
            IList <Store> allStores = _storeService.GetAllStores();

            IList <StoreDto> storesAsDto = new List <StoreDto>();

            foreach (var store in allStores)
            {
                var storeDto = _dtoHelper.PrepareStoreDTO(store);

                storesAsDto.Add(storeDto);
            }

            var storesRootObject = new StoresRootObject()
            {
                Stores = storesAsDto
            };

            var json = _jsonFieldsSerializer.Serialize(storesRootObject, fields);

            return(new RawJsonActionResult(json));
        }