public ConverterListClientModel CreateConverterList(ConverterListClientModel converterListModel)
        {
            // Inserte a ConverterList entry
            var converterListId = _converterListDal.CreateConverterList(converterListModel.DisplayName);

            foreach (var converterModel in converterListModel.Converters)
            {
                // Insert a Converter entry
                var converterId = _converterDal.CreateConverter(converterModel.UnitTypeId);

                // Insert a ConverterIo entry for the converter's input
                _converterIoDal.CreateConverterInput(converterId, converterModel.Input.UnitSymbol, converterModel.Input.Value);

                // Insert ConverterIo entries for the converter's outputs
                foreach (var outputModel in converterModel.Outputs)
                {
                    _converterIoDal.CreateConverterOutput(converterId, outputModel.UnitSymbol);
                }

                // Add the converter to the list
                _converterListDal.AddConverterToList(converterListId, converterId);
            }

            // Construct and return the entity for the new converter list
            return(GetConverterList(converterListId));
        }
Beispiel #2
0
 public ActionResult <ConverterListClientModel> PostConverterList(ConverterListClientModel converterListModel)
 {
     _logger.LogInformation($"PostConverterList: DisplayName: {converterListModel.DisplayName}");
     return(_listsService.CreateConverterList(converterListModel));
 }
Beispiel #3
0
 public ActionResult <ConverterListClientModel> PostConverterList(ConverterListClientModel converterListModel)
 {
     return(_listsService.CreateConverterList(converterListModel));
 }