public async Task <Unit> Handle(CreateIngredientCommand request, CancellationToken cancellationToken) { var user = await _userAuth.GetCurrentUser(); if (user == null) { throw new RestException(HttpStatusCode.Unauthorized, new { User = "******" }); } if (await _ingredient.IsIngredientExitByName(request.Name, user.Id, request.SlugUrl)) { throw new RestException(HttpStatusCode.BadRequest, new { Ingredient_slug = "Already exist" }); } var createIngredient = new Domain.Entities.Ingredients { Name = request.Name, Description = request.Description, SlugUrl = request.SlugUrl }; var success = await _ingredient.Create(user.Id, createIngredient); if (success > 0) { return(Unit.Value); } throw new Exception("Problem saving changes"); }