/// <summary> /// Deletes Single NewsItem From Database by <see cref="DeleteNewsItemViewModel"/> /// </summary> /// <param name="model"></param> /// <returns><see cref="bool"/></returns> public async Task <bool> DeleteSingleNews(DeleteNewsItemViewModel model) { var existingNewsItem = await _healthyGamerPortalDbContext.NewsItem.AsNoTracking().FirstOrDefaultAsync(i => i.Id == model.Id); if (existingNewsItem != null) { _healthyGamerPortalDbContext.Remove(existingNewsItem); await _healthyGamerPortalDbContext.SaveChangesAsync(); return(true); } return(false); }
public async Task <IActionResult> Delete(DeleteNewsItemViewModel model) { if (ModelState.IsValid) { var api = RestService.For <IHealthyGamerPortalNewsApi>(new HttpClient(new Helpers.AuthenticatedHttpClientHandler()) { BaseAddress = new Uri(BaseUrl) }); var response = await api.DeleteSingleNews(model); if (response.Result) { } } return(PartialView("_Delete", model)); }
public async Task <IActionResult> DeleteSingleNews([FromBody] DeleteNewsItemViewModel model) { var result = await _INewsService.DeleteSingleNews(model); return(Ok(GenerateSuccessfulResponse(result))); }