Exemplo n.º 1
0
        public async Task <IActionResult> RankSale([FromBody] SaleViewModel saleViewModel)
        {
            var originalUser = await _helpService.ExistUser(User);

            if (originalUser == null)
            {
                return(BadRequest());
            }

            if (saleViewModel.Id > 0 && saleViewModel.RankSale > 0)
            {
                var user = _catalogService.GetUserByOriginalId(originalUser.Id);

                var amountRanks = await _catalogService.CheckRankSaleUser(saleViewModel.Id, user.Id);

                if (amountRanks > 0)
                {
                    return(BadRequest());
                }

                await _catalogService.AddRankForSale(saleViewModel.Id, saleViewModel.RankSale, user.Id);

                return(Ok());
            }
            return(BadRequest());
        }