예제 #1
0
        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));
        }
예제 #2
0
        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;
                 */
            }
        }