Ejemplo n.º 1
0
        public async Task <IActionResult> LoadModelByIdentifier(
            [FromQuery] string identifier,
            [FromQuery] string sku)
        {
            var parsedModel = await _jewelryModelService.GetActiveJewelryModelByIdentifier(identifier);

            if (parsedModel == null)
            {
                return(NotFound());
            }

            var model = _mapper.Map <JewelryModel>(parsedModel);

            model.SkuDescriptions = (await _skuDescriptionService.LoadSkuDescriptionsByModelId(parsedModel.Id))
                                    .Select(s => _mapper.Map <SkuDescription>(s)).ToList();
            if (string.IsNullOrEmpty(sku))
            {
                return(Ok(model));
            }
            var values = await _jewelryModelService.GetOrderedValues(sku, identifier);

            for (var i = 0; i < model.Configurations.Count; ++i)
            {
                model.Configurations[i].Value = values[i];
            }

            return(Ok(model));
        }
Ejemplo n.º 2
0
 public Task <List <SkuDescriptionDto> > SkuDescriptionsByModelId([FromQuery] int modelId)
 {
     return(_skuDescriptionService.LoadSkuDescriptionsByModelId(modelId));
 }