コード例 #1
0
 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());
         }
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
 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());
         }
     }
 }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            CategoryNew categoryNew = db.CategoryNews.Find(id);

            db.CategoryNews.Remove(categoryNew);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
 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));
 }
コード例 #6
0
        // 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));
        }
コード例 #7
0
 /// <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);
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: Mapping.cs プロジェクト: ericdellis17/JoeBlogs
        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);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: ericdellis17/JoeBlogs
    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
    }
コード例 #11
0
        public string GetCategoryMetaTitle(int id)
        {
            CategoryNew category = db.CategoryNews.Find(id);

            return(category.metaTitle);
        }
コード例 #12
0
        public string GetCategoryNew(int?id)
        {
            CategoryNew category = db.CategoryNews.Find(id);

            return(category.name);
        }