public async Task AddDemoModelAsync(DemoModel model) { var dbModel = new DemoDbModel { Name = model.Name }; var info = await _demoDbModelRepository .GetCommonInfoByCommonInfoAsync(model.CommonInfo); dbModel.DemoCommonInfoModelId = info?.Id ?? 1; await _demoDbModelRepository.AddAsync(dbModel); }
public async Task CreateDemoModelAsync(DemoModel model) { if (model.Name == "bla-bla") { throw new DemoServiceException(DemoServiceException.ErrorType.WrongName); } var dalInfo = Mapper.Map <DemoModel, DemoCommonInfoDbModel>(model); var dalModel = Mapper.Map <DemoModel, DemoDbModel>(model); dalModel = Mapper.Map <DemoCommonInfoDbModel, DemoDbModel>(dalInfo, dalModel); await _demoDbModelRepository.AddAsync(dalModel); }