public PostCategoryViewModel AddPostCategory(PostCategoryViewModel model)
        {
            var postCategory = new PostCategory()
            {
                Title = model.Title
            };

            postCategory.CreateDate = DateTime.Now;
            postCategory.UpdateDate = DateTime.Now;
            //postCategory.UserId = 1;
            //postCategory.CategoryId = 1;
            //postCategory.ClickCount = 1;


            var entity = _postCategoryRepository.Add(postCategory);

            try
            {
                _postCategoryRepository.SaveChanges();
                return(new PostCategoryViewModel()
                {
                    Id = entity.Id, Title = entity.Title
                });
            }
            catch (Exception ex)
            {
                var errorMessage = ex.Message;
                throw;
            }
        }
Exemple #2
0
        public void PostCategory_Repository_Create()
        {
            PostCategory postCategory = new PostCategory();

            postCategory.Name   = "Test-Category";
            postCategory.Alias  = "Test-Category";
            postCategory.Status = true;
            var result = postCategoryRepository.Add(postCategory);

            unitOfWork.Commit();
            Assert.AreEqual(1, result.ID);
        }
Exemple #3
0
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory();

            category.Name   = "Test Category";
            category.Alias  = "test-category";
            category.Status = true;
            var result = objRepository.Add(category);

            unitOfWork.Commit();

            Assert.AreNotSame(55, result.ID);
        }
        public void PostCategory_Repository_Creat()
        {
            PostCategory category = new PostCategory();

            category.Name   = "Test category";
            category.Alias  = "Test category";
            category.Status = true;
            var result = objRepository.Add(category);

            unitOfWork.Commit();
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
        public void PostCategoryRepository_Add()
        {
            PostCategory postCategory = new PostCategory();

            postCategory.Name       = "Post Category 1";
            postCategory.Alias      = "PostCategory1";
            postCategory.CreateDate = DateTime.Now;
            postCategory.Status     = true;
            var result = objRepository.Add(postCategory);

            _unitOfWork.Commit();
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
Exemple #6
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create(PostCategoryViewModel categoryVM)
        {
            if (ModelState.IsValid)
            {
                var data = Mapper.Map <PostCategory>(categoryVM);
                _postCategory.Add(data);
                _postCategory.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var parent = _postCategory.Find(x => x.ParentId == null);

            ViewBag.Parent = parent;
            return(View());
        }
Exemple #7
0
        public void PostCategory_Repository_create()
        {
            PostCategory category = new PostCategory();

            category.Name  = "test";
            category.Alias = "testalias";

            var result = postCategoryRepository.Add(category);

            unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
        public void PostCategory_Post_CreatePostCategory()
        {
            PostCategory cate = new PostCategory();

            cate.Name   = "Test 1";
            cate.Alias  = "Test1";
            cate.Status = true;

            var result = objPostCateRep.Add(cate);

            unitOfWork.Commit();

            Assert.AreEqual(1, result.ID);
        }
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory();

            category.Name        = "Tin Mới Nhất";
            category.Alias       = "tin-moi-nhat";
            category.CreatedDate = DateTime.Now;
            category.CreateBy    = "HuyManager";
            category.Status      = true;
            var result = _postCategoryRepository.Add(category);

            _unitOfWork.Commit();
            Assert.IsNotNull(result);
        }
        public void PostCategory_Repository_Create()
        {
            PostCategory ps = new PostCategory();

            ps.Name   = "jfjf";
            ps.Alias  = "test 1";
            ps.Status = true;
            var resuilt = objRepository.Add(ps);

            unitOfWork.Commit();

            Assert.IsNotNull(resuilt);
            Assert.AreEqual(1, resuilt.ID);
        }
        public void PostCategory_Repository_Add()
        {
            PostCategory p = new PostCategory();

            p.Name        = "Ao Nam";
            p.Alias       = "ao-nam";
            p.Description = "áo phông, sơ mi, khoác ...";
            p.Status      = true;
            var result = _postCategoryRepository.Add(p);

            _unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
        public void PostCategory_Repository_AddCreate()
        {
            PostCategory postCategory = new PostCategory();

            postCategory.Name   = "Test postCategory";
            postCategory.Alias  = "Test-postCategory";
            postCategory.Status = true;

            var result = objRepository.Add(postCategory);

            unitOfWork.Commit();
            //kiểm thử
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Id);
        }
        [TestMethod] //nhận tên phương thức trong TestExploer
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory();

            category.Name   = "Test category";
            category.Alias  = "Test-category";
            category.Status = true;

            var result = objRepository.Add(category);

            unitOfWork.Commit();

            //Asert chứa các phương thức để so sánh giữa hai giá trị
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory();

            category.Name   = "Test Category";
            category.Alias  = "Test Category";
            category.Status = true;

            //Nếu thành công trả về 1
            var result = objRepository.Add(category);

            unitOfWork.Commit();
            //Phương thức dùng để so sánh..
            Assert.IsNotNull(result);
            Assert.AreEqual(7, result.ID);
        }
Exemple #15
0
        public void PostCategory_Repository_Create()
        {
            PostCategory postCategory = new PostCategory();

            postCategory.Name   = "A";
            postCategory.Alias  = "B";
            postCategory.Status = true;

            var result = iPostCategoryRepository.Add(postCategory);

            iUnitOfWork.Commit();

            Assert.IsNotNull(result);

            Assert.AreEqual(3, result.ID);
        }
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory
            {
                Name   = "Test category",
                Alias  = "Test-category",
                Status = true
            };

            var result = objRepostitory.Add(category);

            unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.ID);
        }
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory();

            category.Name         = "Test category";
            category.Alias        = "test-category";
            category.ParentID     = 0;
            category.DisplayOrder = 1;
            category.Status       = true;

            var result = objRepository.Add(category);

            unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.ID);
        }
Exemple #18
0
        public void PostCategory_Repository_Create()
        {
            PostCategory category = new PostCategory();

            //Gán cho các trường not null
            category.Name   = "Test category";
            category.Alias  = "Test-category";
            category.Status = true;

            var result = objRepository.Add(category);

            unitOfWork.Commit();

            //Assert: Giá trị muốn so sánh giữa 2 đối tượng
            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.ID);
        }
Exemple #19
0
        public void PostCategory_Repository_Create()
        {
            PostCategory pc = new PostCategory();

            pc.Name  = "C# Cơ bản";
            pc.Alias = "c-co-ban";

            pc.Status      = true;
            pc.CreatedDate = DateTime.Now;

            var result = _postCategoryRepository.Add(pc);

            _unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
        public void PostCategory_Repository_Create()
        {
            PostCategory obj = new PostCategory()
            {
                Name        = "post category test",
                Alias       = "post-category-test",
                CreatedDate = DateTime.Now,
                UpdatedDate = DateTime.Now,
                Status      = true
            };

            var result = objRepository.Add(obj);

            unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(9, result.ID);
        }
Exemple #21
0
 public PostCategory Add(PostCategory model)
 {
     return(_postCategoryRepository.Add(model));
 }
 public void CreatePostCategory(PostCategory postCategory)
 {
     postCategoryRepository.Add(postCategory);
 }
Exemple #23
0
 public PostCategory Add(PostCategory entity)
 {
     return(_postCategoryRepository.Add(entity));
 }
 public PostCategory Add(PostCategory postCategory)
 {
     _postCategoryRepository.Add(postCategory);
     return(postCategory);
 }
 public PostCategory Create(PostCategory postCategory)
 {
     return _postCategoryRepository.Add(postCategory);
 }
 public void Add(PostCategory postCategory)
 {
     _postCategoryRepository.Add(postCategory);
 }
 public PostCategory Add(PostCategory postCategory)
 {
     return(_postCategoryRepository.Add(postCategory));
 }
Exemple #28
0
 public void Add(PostCateGory entity)
 {
     _postCategorrepository.Add(entity);
 }