public async Task <ActionResult <IEnumerable <BetDTO> > > PutCloseRoulette(long id) { Response response = await rouletteServices.ValidateCloseRoulette(id); if (response.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(response)); } Response responseChange = await rouletteServices.ChangeRouletteState(id, false); if (responseChange.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(responseChange)); } var responseBets = await betServices.GetAllBetsByRoulleteId(id); if (responseBets.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(responseBets)); } return(MappersFactory.BetDTO().ListMap(responseBets.List)); }
public async Task <ActionResult <IEnumerable <BetDTO> > > GetBets() { ResponseList <Bet> responseBets = await betServices.GetAllBets(); if (responseBets.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(responseBets)); } return(MappersFactory.BetDTO().ListMap(responseBets.List)); }
public async Task <ActionResult <BetDTO> > GetBet(long id) { Response response = await betServices.ValidateBetToRead(id); if (response.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(response)); } ResponseEntity <Bet> responseBet = await betServices.GetBetById(id); if (responseBet.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(responseBet)); } return(MappersFactory.BetDTO().Map(responseBet.Entity)); }
public async Task <ActionResult <Bet> > PostBet(Bet bet) { Response response = await betServices.ValidateBetToSave(bet); if (response.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(response)); } response = await betServices.SaveBet(bet); if (response.Code.Equals(Enumerators.State.Error.GetDescription())) { return(BadRequest(response)); } return(CreatedAtAction(nameof(GetBet), new { id = bet.Id }, MappersFactory.BetDTO().Map(bet))); }