public async Task<IActionResult> GetById(int id, string languageId)
 {
     var product = await _manageProductService.GetById(id, languageId);
     if (product == null)
         return BadRequest("Cannot find product");
     return Ok(product);
 }
Пример #2
0
        public async Task <IActionResult> GetById(int productId, string languageId)
        {
            var product = await _manageProductService.GetById(productId, languageId);

            if (product == null)
            {
                return(BadRequest("Cannot Find Product"));
            }
            return(Ok(product));
        }
Пример #3
0
        public async Task <ActionResult> GetById(int id, string languageId)
        {
            var result = await _manageProductService.GetById(id, languageId);

            if (result == null)
            {
                return(BadRequest());
            }
            return(Ok(result));
        }
        public async Task <IActionResult> Create([FromForm] ProductCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var productId = await _manageProductService.Create(request);

            if (productId == 0)
            {
                return(BadRequest());
            }
            var product = await _manageProductService.GetById(productId, request.LanguageId);

            return(CreatedAtAction(nameof(GetById), new { id = productId }, product));
        }