public async Task <StoryEntity> CreateStory(StoryEntity storyEntity) { var storyAssembler = new StoryAssembler(); var de = storyAssembler.DtoToDomainEntity(storyEntity); _storyRepository.Create(de); if (!(await _storiesUoW.CommitAsync())) { return(null); } return(storyAssembler.DomainEntityToDto(de)); }
public IActionResult Create([FromBody] Story toCreate) { if (IsProjectActive(toCreate.projectId).GetAwaiter().GetResult()) { var created = repo.Create(toCreate); return(CreatedAtRoute("GetStory", new { id = created.id }, created)); } else { return(new StatusCodeResult(422)); /* //Another way of doing it * var result = new JsonResult(null); * result.StatusCode = 422; * return result; */ } }