public ActionResult <bool> DeleteVote(int songId, int id) { try { return(Ok(service.DeleteVote(songId, id))); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public async Task Should_DeleteVotesOfPoll() { var poll = new PolicyChangePoll { Name = "test", Active = true, CreateTime = DateTime.UtcNow, QuestionBody = "test dfs", TenantId = "test" }; _context.Polls.Add(poll); var userList = new List <ApplicationUser> { new ApplicationUser { Email = "*****@*****.**", FirstName = "test", LastName = "Test", TenantId = "test", CreatedAt = DateTime.UtcNow, SecurityStamp = new Guid().ToString(), EmailConfirmed = false, Id = 1.ToString(), IsDeleted = false, UserDetail = new UserDetail { AuthorityPercent = 20, LanguagePreference = "tr" } } }; _context.Users.AddRange(userList); _context.SaveChanges(); _context.Votes.Add(new Vote { PollId = poll.Id, Value = 1, VoterId = 1.ToString() }); _context.SaveChanges(); await _voteService.DeleteVote(poll.Id); var result = _context.Votes.Where(x => x.PollId == poll.Id); Assert.Equal(0, result.Count()); }
public ActionResult Delete(int id) { voteService.DeleteVote(id); return(RedirectToAction("Index", "Genre")); }
public async Task DeletePoll(long id) { await _voteService.DeleteVote(id); await _pollRepository.DeletePoll(id); }