示例#1
0
        public async Task <IActionResult> BuyItem([FromBody] BuyItemViewmodel model)
        {
            if (User.Identity.IsAuthenticated)
            {
                var accountName = HttpContext.GetUsername();

                var response = await _requestService.BuyItem(accountName, model.Username, model.ItemId, model.ItemCount, model.Enchant, model.Price);

                switch (response.ResponseCode)
                {
                case 200:
                    return(Content("paid:" + model.Price));

                case 500:
                    return(Content(_localizer["Invalid request!"]));

                case 501:
                    return(Content(_localizer["Not enough donate points"]));

                default:
                    return(Content(_localizer["Invalid request!"]));
                }
            }
            return(Unauthorized());
        }
        public async Task <IActionResult> BuyItem([FromBody] BuyItemViewmodel model)
        {
            if (User.Identity.IsAuthenticated)
            {
                var accountName = HttpContext.GetUsername();

                var response = await _requestService.BuyItem(accountName, model.Username, model.ItemId, model.ItemCount, model.Enchant, model.Price);

                if (response.ResponseCode == 200)
                {
                    return(Content("paid:" + model.Price));
                }
                return(Content(response.ResponseMessage));
            }
            return(Unauthorized());
        }