Beispiel #1
0
        public BaseResponse <Drink> AddDrink(Drink drink)
        {
            if (drink == null || drink.Id == Guid.Empty)
            {
                return(new BaseResponse <Drink>(ResultCodeEnum.InvalidData));
            }

            var drinkInDb = dataLayer.GetDrinksByIdOrName(id: drink.Id, name: drink.Name).FirstOrDefault();

            if (drinkInDb == null)
            {
                dataLayer.Insert(drink);
            }
            else
            {
                return(new BaseResponse <Drink>(ResultCodeEnum.Fail));
            }
            return(new BaseResponse <Drink>(ResultCodeEnum.Success, resultItem: drink));
        }