Example #1
0
        public async Task <IActionResult> Create([FromForm(Name = "catalog")] CatalogDto catalogDto)
        {
            try
            {
                var formFile = Request.Form.Files.FirstOrDefault(a => a.Name == "image");

                var fileData = _mapper.Map <FileData>(formFile);
                await _catalogService.CreateCatalogAsync(catalogDto, fileData);

                return(CreatedAtAction(nameof(GetById), new { catalogId = catalogDto.Id }, catalogDto));
            }
            catch
            {
                return(BadRequest());
            }
        }