public JsonResult AddDrink(string name, int cost, int count, string imgPath)
        {
            _logger.Info("");
            _logger.Info(" AddDrink() called...");
            _logger.Info("   name = " + name);
            _logger.Info("   cost = " + cost);
            _logger.Info("   count = " + count);
            _logger.Info("   img = " + imgPath);

            if (!Validate.ValidateCost(cost))
            {
                return(JsonErrorCost());
            }

            if (!Validate.ValidateCount(count))
            {
                return(JsonErrorCount());
            }

            DrinkOperationInfo operationInfo = _adminService.AddDrink(name, cost, count, imgPath);

            return(Json(new { success = operationInfo.Success, message = operationInfo.Msg,
                              id = operationInfo.Drink.Id, name = operationInfo.Drink.Name,
                              cost = operationInfo.Drink.CostPrice, count = operationInfo.Drink.Count, path = operationInfo.Drink.ImagePath }));
        }
Exemplo n.º 2
0
        public JsonResult BuyDrink(Guid id)
        {
            _logger.Info("");
            _logger.Info(" BuyDrink() called...");
            _logger.Info(" id = " + id);

            DrinkOperationInfo drinkOperationInfo = _userService.BuyDrink(id);

            return(Json(new { success = drinkOperationInfo.Success, msg = drinkOperationInfo.Msg, change = drinkOperationInfo.Change, id = drinkOperationInfo.Drink.Id, count = drinkOperationInfo.Drink.Count }));
        }