public IActionResult Delete(int gameId) { var userId = Convert.ToInt32(User.Identity.Name); _ratingService.Delete(userId, gameId); return(StatusCode(StatusCodes.Status200OK)); }
public IHttpActionResult Delete(int id) { using (_ratingService) { _ratingService.Delete(id); } return(Ok()); }
public IActionResult DeleteRating(int id) { Rating rating = _service.Delete(id); if (rating == null) { return(NotFound()); } return(Ok(rating)); }
public IActionResult Delete(int id) { if (id <= 0) { return(BadRequest()); } var result = _ratingSer.Delete(id); if (!result) { return(NotFound()); } return(NoContent()); }
public async Task <bool> DeleteRatingAsync(Guid ratingId) { using (var uow = UnitOfWorkProvider.Create()) { if (await _ratingService.GetAsync(ratingId, false) == null) { return(false); } _ratingService.Delete(ratingId); await uow.Commit(); return(true); } }
public void DeleteRating_WhereRatingExists_ReturnsOkResponse([Values(1, 2, 3)] int ratingIdToDelete) { //arrange Mock.Arrange(() => _ratingService.Delete(ratingIdToDelete)).OccursOnce(); var ratingController = new RatingController(_ratingService); //act var actual = ratingController.Delete(ratingIdToDelete) as OkResult; //assert Mock.Assert(_ratingService); Assert.That(actual, Is.TypeOf <OkResult>()); }
public ActionResult DeleteRating(int ratingId) { try { if (!ModelState.IsValid) { throw new Exception(ModelState.ToString()); } _ratingService.Delete(ratingId); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Delete(int Id) { try { var curvePoint = _ratingService.FindById(Id); if (curvePoint == null) { return(NotFound()); } _ratingService.Delete(Id); return(Ok()); } catch (Exception e) { return(BadRequest(e)); } }
public IActionResult Delete(int id) { var viewModel = newsService.Get(id); foreach (var rating in viewModel.Ratings) { ratingService.Delete(rating.Id); } foreach (var comment in viewModel.Commentaries) { foreach (var like in comment.Likes) { likeService.Delete(like.Id); } commentaryService.Delete(comment.Id); } newsService.Delete(id); return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { AppLogger.LogResourceRequest(nameof(Delete), base.GetUsernameForRequest()); try { var checkRating = _ratingService.FindById(id); if (checkRating == null) { return(NotFound(AppConfig.ResourceNotFoundById + id)); } _ratingService.Delete(id); return(Ok()); } catch (Exception ex) { return(BadRequestExceptionHandler(ex, nameof(Delete))); } }
public async Task <ActionResult> Delete(string id) { User user = await _userManager.FindByIdAsync(id); var deletedNews = new List <NewsViewModel>(); var news = newsService.GetAll(); foreach (var authorNews in news) { if (authorNews.AuthorId == Convert.ToInt32(id)) { newsService.Delete(authorNews.Id); foreach (var rating in authorNews.Ratings) { ratingService.Delete(rating.Id); } foreach (var comment in authorNews.Commentaries) { foreach (var like in comment.Likes) { likeService.Delete(like.Id); } commentaryService.Delete(comment.Id); } } } var ratings = ratingService.GetAll(); foreach (var rating in ratings) { if (rating.UserId == Convert.ToInt32(id)) { ratingService.Delete(rating.Id); } } var commentaries = commentaryService.GetAll(); foreach (var comment in commentaries) { if (comment.AuthorId == Convert.ToInt32(id)) { var likes = likeService.GetAll(comment.Id); if (likes != null) { foreach (var like in likes) { likeService.Delete(like.Id); } } commentaryService.Delete(comment.Id); } else { var likes = likeService.GetAll(comment.Id); foreach (var like in likes) { if (like.AuthorId == Convert.ToInt32(id)) { likeService.Delete(like.Id); } } } } if (user != null) { IdentityResult result = await _userManager.DeleteAsync(user); } return(RedirectToAction("Index")); }
public void Delete(int id) { _ratingService.Delete(id); }