public IActionResult AddPostCategory(APostCategoryModel model) { var data = postCategory.GetAllFromTable(); var oldData = from item in data where item.CategoryID.Equals(model.CategoryID) && item.PostID.Equals(model.PostID) select item; var d = oldData.FirstOrDefault(); if (d == null) { postCategory.InsertIntoTable(model); postCategory.Save(); return(Ok(HttpStatusCode.OK)); } return(BadRequest()); }
public IActionResult AddPostCategory(APostCategoryModel model) { var cookieToken = HttpContext.User.Claims.First(c => c.Type == "_token").Value; var _http = client.CreateClient("apiClient"); _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", cookieToken); var response = _http.PostAsJsonAsync("Post/AddPostCategory", model).Result; if (response.StatusCode == HttpStatusCode.OK) { return(RedirectToAction("ShowPosts", "Post")); } else { return(RedirectToAction("PageNotFound", "Access")); } }
public IActionResult DeletePostCategory(APostCategoryModel model) { postCategory.DeleteFromPostCategoryTable(model); postCategory.Save(); return(Ok(HttpStatusCode.OK)); }