public async Task <IActionResult> DeleteBet(int betId)
        {
            try
            {
                var existingBet = await _betRepository.GetBet(betId);

                if (existingBet == null)
                {
                    return(NotFound());
                }

                var user = await GetUser();

                if (existingBet.User.Id != user.Id)
                {
                    return(BadRequest());
                }

                _betRepository.DeleteBet(existingBet);

                if (!await _betRepository.Save())
                {
                    return(GetErrorStatusCodeAndGenericMessage());
                }

                return(NoContent());
            }
            catch (Exception)
            {
                return(GetErrorStatusCodeAndGenericMessage());
            }
        }
        public async Task <IActionResult> DeleteBet(int id)
        {
            await betRepository.DeleteBet(id);

            return(RedirectToAction("GetBets"));
        }
Beispiel #3
0
        public async Task DeleteBet(string shortName)
        {
            await _betRepository.DeleteBet(shortName.ToLower().Trim());

            await ReplyAsync($"{shortName} deleted");
        }
Beispiel #4
0
 public HttpResponseMessage DeleteBetById(int betId)
 {
     repository.DeleteBet(betId);
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }