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)); }
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); }
public CommandModel Create(CommandModel command) { _repository.Create(command); return(command); }