示例#1
0
        public void PostCategory_Repository_Create()
        {
            PostCategorie category = new PostCategorie();

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

            var result = objRepository.Add(category);

            unitOfWork.Commit();

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.ID);
        }
示例#2
0
        public static void UpdatePostCategory(this PostCategorie postCategory, PostCategoryViewModel postCategoryVm)
        {
            postCategory.ID           = postCategoryVm.ID;
            postCategory.Name         = postCategoryVm.Name;
            postCategory.Description  = postCategoryVm.Description;
            postCategory.Alias        = postCategoryVm.Alias;
            postCategory.PrentID      = postCategoryVm.PrentID;
            postCategory.DisplayOrder = postCategoryVm.DisplayOrder;
            postCategory.Image        = postCategoryVm.Image;
            postCategory.HomeFlag     = postCategoryVm.HomeFlag;

            postCategory.CreateDate      = postCategoryVm.CreatedDate;
            postCategory.CreateBy        = postCategoryVm.CreatedBy;
            postCategory.UpdateDate      = postCategoryVm.UpdatedDate;
            postCategory.UpdateBy        = postCategoryVm.UpdatedBy;
            postCategory.MetaKeyword     = postCategoryVm.MetaKeyword;
            postCategory.MetaDescription = postCategoryVm.MetaDescription;
            postCategory.Status          = postCategoryVm.Status;
        }
        public void PostCategory_Service_Create()
        {
            PostCategorie category = new PostCategorie();
            int           id       = 1;

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

            _mockRepository.Setup(m => m.Add(category)).Returns((PostCategorie p) =>
            {
                p.ID = 1;
                return(p);
            });

            var result = _categoryService.Add(category);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ID);
        }
        public HttpResponseMessage Post(HttpRequestMessage request, PostCategoryViewModel postCategoryVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    PostCategorie newPostCategory = new PostCategorie();
                    newPostCategory.UpdatePostCategory(postCategoryVm);

                    var category = _postCategoryService.Add(newPostCategory);
                    _postCategoryService.Save();

                    response = request.CreateResponse(HttpStatusCode.Created, category);
                }
                return response;
            }));
        }
 public void Update(PostCategorie postCategory)
 {
     _postCategoryRepository.Update(postCategory);
 }
 public PostCategorie Add(PostCategorie postCategory)
 {
     return(_postCategoryRepository.Add(postCategory));
 }