public async Task <ActionResult <List <KitchenIngredientDto> > > GetIngredientsForKitchen(long kitchenId) { PantryPlannerUser user; try { user = await _userManager.GetUserFromCookieOrJwtAsync(this.User); List <KitchenIngredient> ingredientsInKitchen = _service.GetKitchenIngredients(kitchenId, user); return(Ok(KitchenIngredientDto.ToList(ingredientsInKitchen))); } catch (ArgumentNullException e) { return(BadRequest(e.Message)); } catch (KitchenNotFoundException e) { return(NotFound(e.Message)); } catch (PermissionsException e) { return(Unauthorized(e.Message)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public void GetKitchenIngredients_NullArguments_ThrowsArgumentNullException() { Kitchen kitchen = _testUser.KitchenUser.FirstOrDefault().Kitchen; if (kitchen == null) { throw new ArgumentNullException("kitchen is not setup for testing"); } Assert.Throws <ArgumentNullException>(() => { _service.GetKitchenIngredients(null, _testUser); }); Assert.Throws <ArgumentNullException>(() => { _service.GetKitchenIngredients(kitchen, null); }); }