Exemple #1
0
        public async Task <ActionResult <Product> > UpdateProduct([FromBody] Product product)
        {
            try
            {
                if (!await User.IsPlaceProviderAdmin(userRepository, placeProviderRepository))
                {
                    throw new Exception(localizer[Resources.Controllers_AdminController.Only_admin_is_allowed_to_invite_other_users].Value);
                }

                product.LastUpdate = DateTimeOffset.Now;
                return(Ok(await placeProviderRepository.SetProduct(User.GetPlaceProvider(), product)));
            }
            catch (ArgumentException exc)
            {
                logger.LogError(exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
            catch (Exception exc)
            {
                logger.LogError(exc, exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
        }