Пример #1
0
        public async Task <CocktailDTO> CreateCocktail(CocktailDTO cocktailDTO)
        {
            if (cocktailDTO == null)
            {
                throw new ArgumentNullException("Cocktail doesn't exist!");
            }

            var cocktail = cocktailDTO.CocktailDTOMapToModel();

            await _cmContext.Cocktails.AddAsync(cocktail);

            await _cmContext.SaveChangesAsync();

            return(cocktailDTO);
        }
Пример #2
0
        public void Return_Cocktail()
        {
            var cocktail = new CocktailDTO()
            {
                Id          = Guid.Parse("9ef97551-87f6-40ce-a88b-6c0e876ccb51"),
                Name        = "Margarita",
                Description = "The Margarita is one of the most " +
                              "popular cocktails in North America—for good reason. " +
                              "Combining the tang of lime and the sweetness of o" +
                              "range liqueur with the distinctive strength of " +
                              "tequila, our classic Margarita strikes all of the right keys."
            };

            var result = cocktail.CocktailDTOMapToModel();

            Assert.IsInstanceOfType(result, typeof(Cocktail));
        }