Example #1
0
        public async Task<IActionResult> CreateProductPicture(string key, [FromBody] ProductPictureDto productPicture)
        {
            if (productPicture == null)
                return NotFound();

            if (!await _permissionService.Authorize(PermissionSystemName.Products))
                return Forbid();

            var product = await _productApiService.GetById(key);
            if (product == null)
            {
                return NotFound();
            }

            var pp = product.Pictures.Where(x => x.PictureId == productPicture.PictureId).FirstOrDefault();
            if (pp != null)
                ModelState.AddModelError("", "Product picture mapping found with the specified pictureid");

            if (ModelState.IsValid)
            {
                await _productApiService.InsertProductPicture(product, productPicture);
                return Ok(true);
            }
            return BadRequest(ModelState);
        }