示例#1
0
        public void Creat(CreateArticleCategory creatArticelCategory)
        {
            var articelCategory = new ArticleCategory(creatArticelCategory.Title);

            _ArcRep.CreateArticleCategory(articelCategory);
            _ArcRep.Save();
        }
        public OperationResult Create(CreateArticleCategory command)
        {
            var result = new OperationResult("ArticleCategory", "Create");

            try
            {
                if (command == null || string.IsNullOrEmpty(command.CategoryName) || string.IsNullOrEmpty(command.Slug) || string.IsNullOrEmpty(command.Description))
                {
                    return(result.Failed(ApplicationMessages.EmptyFields));
                }

                if (_articleCategoryRepository.IsDuplicated(x => x.CategoryName == command.CategoryName))
                {
                    return(result.Failed(ApplicationMessages.DuplicatedRecord));
                }

                var slug = command.Slug.GenerateSlug();
                if (_articleCategoryRepository.IsDuplicated(x => x.Slug == slug))
                {
                    return(result.Failed(ApplicationMessages.DuplicatedSlug));
                }

                var articleCategory = new ArticleCategory(command.CategoryName, command.Description, command.DisplayOrder, command.Image, command.ParentId, command.Keywords, command.MetaDescription, command.Slug, command.CanonicalAddress);
                _articleCategoryRepository.Create(articleCategory);
                _articleCategoryRepository.SavaChanges();

                return(result.Succeeded(ApplicationMessages.OperationSuccess));
            }
            catch (Exception)
            {
                return(result.Failed(ApplicationMessages.SystemFailure));
            }
        }
示例#3
0
        public OperationResult Create(CreateArticleCategory command)
        {
            var operation = new OperationResult();

            if (_articleCategoryRepository.Exists(x => x.Name == command.Name))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }

            var slug = command.Slug.Slugify();



            var picturePath = $"{command.Slug}";
            var pictureName = _fileUploader.Upload(command.Picture, picturePath);



            //var pictureName = _fileUploader.Upload(command.Picture, slug);

            var articleCategory = new ArticleCategory(command.Name, pictureName,
                                                      command.PictureAlt, command.PictureTtile, command.Description, command.ShowOrder,
                                                      slug, command.Keywords, command.MetaDescription, command.CanonicalAddress);

            _articleCategoryRepository.Create(articleCategory);
            _articleCategoryRepository.SaveChanges();
            return(operation.Succeeded());
        }
        public void Create(CreateArticleCategory command)
        {
            _unitOfWork.BeginTran();
            var articleCategory = new ArticleCategory(command.Title, _articleCategoryValidatorService);

            _articleCategoryRepository.Create(articleCategory);
            _unitOfWork.CommitTran();
        }
示例#5
0
        public void Create(CreateArticleCategory command)
        {
            _unitOfWork.BeginTran();
            var articleCategory = new ArticleCategory(command.Title);

            _articleCategoryRepository.Add(articleCategory);
            _unitOfWork.CommitTran();
        }
        public OperationResult Create(CreateArticleCategory command)
        {
            OperationResult operationResult = new OperationResult();

            if (_articleCategoryRepo.Exists(c => c.Name == command.Name))
            {
                return(operationResult.Failed(ApplicationMessage.duplicated));
            }

            var slug = command.Slug.Slugify();

            var Acategory = new ArticleCategory(command.Name, command.Description, slug,
                                                command.ShowOrder, command.KeyWords, command.MetaDescription, command.CanonicalAddress);

            _articleCategoryRepo.Create(Acategory);
            _articleCategoryRepo.Save();
            return(operationResult.Succeeded());
        }
 public ActionResult CreatePost(CreateArticleCategory model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var entity = new ArticleCategory();
             Mapper.Map(model, entity);
             _unitOfWork.ArticleCategoryRepository.Insert(entity);
             _unitOfWork.Save();
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
     return(View());
 }
        public JsonResult OnPostCreate(CreateArticleCategory command)
        {
            var result = _articleCategoryApplication.Create(command);

            return(new JsonResult(result));
        }
示例#9
0
        public IActionResult OnGetCreate()
        {
            var commnd = new CreateArticleCategory();

            return(Partial("./Create", commnd));
        }
示例#10
0
        public void Create(CreateArticleCategory command)
        {
            var articleCategory = new ArticleCategory(command.Title);

            _articleCategoryRepository.Add(articleCategory);
        }
示例#11
0
 public RedirectToPageResult OnPost(CreateArticleCategory command)
 {
     _articleCategoryApplication.Create(command);
     return(RedirectToPage("List"));
 }
示例#12
0
        public void Create(CreateArticleCategory command)
        {
            var aricleCategory = new ArticleCategory(command.Title, _articleCategoryValidatorService);

            _articleCategoryRepository.Add(aricleCategory);
        }
示例#13
0
        public IActionResult OnPost(CreateArticleCategory command)
        {
            _articleCategoryApplication.Creat(command);

            return(RedirectToPage("index"));
        }
 public ActionResult Create(CreateArticleCategory model)
 {
     return(View(model));
 }