示例#1
0
        public async Task <IActionResult> Create([FromBody] EventCollectionDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.FormatErrors()));
            }

            var collection = new EventCollection();

            dto.CopyTo(collection);
            await _eventCollectionManagementService.CreateCollectionAsync(collection);

            return(Ok(new EventCollectionDto(collection)));
        }
        public async Task <IActionResult> Create([FromBody] EventCollectionDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.FormatErrors()));
            }

            try
            {
                var collection = new EventCollection();
                dto.CopyTo(collection);
                await _service.CreateCollectionAsync(collection);

                return(Ok());
            }
            catch (NotAccessibleException e)
            {
                return(NotFound(e.Message)); // FIXME: can't return FORBIDDEN, it will redirect to login page!
            }
        }