コード例 #1
0
        public ActionResult <CommandReadDto> Create(CommandCreateDto commandCreateDto)
        {
            var commandModel = _mapper.Map <Command>(commandCreateDto);

            _repository.Create(commandModel);
            _repository.SaveChanges();
            var createResult = _mapper.Map <CommandReadDto>(commandModel);

            return(CreatedAtRoute(nameof(GetById), new { createResult.Id }, createResult));
        }
コード例 #2
0
        public bool Add(Input.CategoryCreateModel category, out CategoryReadModel createdCategory)
        {
            var commandDatabaseModel = _mapper.Map <Database.CategoryModel>(category);

            try
            {
                _repository.Create(commandDatabaseModel);
                _repository.SaveChanges();
            }
            catch (Exception exception)
            {
                //TODO: Beef this up for real production environment
                _logger.LogError("Something went Boom", exception);
                createdCategory = null;
                return(false);
            }

            createdCategory = _mapper.Map <CategoryReadModel>(commandDatabaseModel);
            return(true);
        }
コード例 #3
0
ファイル: CommandDAL.cs プロジェクト: phillipc47/CommanderAPI
        public CommandModel Create(CommandModel command)
        {
            _repository.Create(command);

            return(command);
        }