public IActionResult Delete([FromBody] CategoryNew item) { if (item.name == "" || item.name == null || item.name == string.Empty) { return(NotFound()); } else { try { if (catefunction.Delete(item)) { return(Ok()); } else { return(NotFound()); } } catch { return(NotFound()); } } }
/// <summary> /// Insert new Category /// </summary> /// <param name="item">infomation cate</param> /// <returns>return false is fail to insert</returns> public bool Post(CategoryNew item) { try { List <Category> list = Get(); foreach (var value in list) { if (item.name == value.name) { return(false); } } Category cate = new Category { idcategory = Guid.NewGuid(), name = item.name }; this._context.PdbCategory.Add(cate); this._context.Entry(cate).State = Microsoft.EntityFrameworkCore.EntityState.Added; this._context.SaveChanges(); return(true); } catch { return(false); } }
public IActionResult Post([FromBody] CategoryNew item) { if (item == null) { return(NotFound()); } else { try { if (catefunction.Post(item)) { return(Ok()); } else { return(NotFound()); } } catch (Exception) { return(NotFound()); } } }
public ActionResult DeleteConfirmed(int id) { CategoryNew categoryNew = db.CategoryNews.Find(id); db.CategoryNews.Remove(categoryNew); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,Description,Detail,Status,CreateDate,CreateBy,ModifiedDate,ModifiedBy,ShowOnHome")] CategoryNew categoryNew) { if (ModelState.IsValid) { db.Entry(categoryNew).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(categoryNew)); }
// GET: Admin/CategoryNews/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CategoryNew categoryNew = db.CategoryNews.Find(id); if (categoryNew == null) { return(HttpNotFound()); } return(View(categoryNew)); }
/// <summary> /// Delete Category /// </summary> /// <param name="_name">name of Category</param> /// <returns>return false if fail to delete</returns> public bool Delete(CategoryNew item) { try { Category cate = this._context.PdbCategory.Single(item1 => item1.name == item.name); this._context.PdbCategory.Remove(cate); this._context.Entry(cate).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; return(this._context.SaveChanges() == 1); } catch { return(false); } }
public void can_map_from_categoryNew_to_xmlRpcCategoryNew() { var categoryNew = new CategoryNew { Name = "Test Category Name", Description = "This is a test category", ParentCategoryID = 1, Slug = "a-slug" }; var result = Map.From.CategoryNew(categoryNew); Assert.AreEqual(categoryNew.Name, result.name); Assert.AreEqual(categoryNew.Description, result.description); Assert.AreEqual(categoryNew.ParentCategoryID.ToString(), result.parentId.ToString()); Assert.AreEqual(categoryNew.Slug, result.slug); }
static void Main(string[] args) { //remember to include the http:// string Url = "http://joeblogstest.alexjamesbrown.com/xmlrpc.php"; //change this to the location of your xmlrpc.php file //typically http://www.yourdomain.com/xmlrpc.php (if your wordpress blog is installed in root dir) string User = "******"; //enter your username string Password = "******"; //enter your password _wpWrapper = new WordPressWrapper(Url, User, Password); #region Posts //create a new post var newPostID = createNewPost(); //edit the post created above editPost(newPostID); //delete post created above _wpWrapper.DeletePost(newPostID); //get list of post status' var statusList = _wpWrapper.GetPostStatusList(); #endregion #region Authors _wpWrapper.GetAuthors(); #endregion #region Pages //create new page var newpageID = createPage(); //get list of pages var pageList = _wpWrapper.GetPageList(); //delete page var pageHasBeenDeleted = _wpWrapper.DeletePage(newpageID); //get page (using the ID from the page created above) var page = _wpWrapper.GetPage(newpageID); //todo: edit page #endregion #region Category //create a category var category = new CategoryNew { Description = "This is a test description", Name = "Alex Cat", Slug = "testSlug" }; var catID = _wpWrapper.NewCategory(category); var cats = _wpWrapper.GetCategories(); var deletedCat = _wpWrapper.DeleteCategory(catID); #endregion #region Comments //create a new post var newPostForComment = createNewPost(); var comment = new Comment(newPostForComment) { AuthorEmail = "*****@*****.**", AuthorName = "Joe Blogs", Content = "This is a bit of text for the comment", AuthorUrl = "www.alexjamesbrown.com" }; //add a comment to this post _wpWrapper.NewComment(newPostForComment, comment); #endregion }
public string GetCategoryMetaTitle(int id) { CategoryNew category = db.CategoryNews.Find(id); return(category.metaTitle); }
public string GetCategoryNew(int?id) { CategoryNew category = db.CategoryNews.Find(id); return(category.name); }