Пример #1
0
        public IResult AddCategory(Category category, int mainCategoryId = -1)
        {
            if (mainCategoryId == -1)
            {
                try
                {
                    _categoryDal.Add(category);
                    return(new SuccessResult());
                }
                catch (Exception)
                {
                    return(new ErrorResult(Messages.ErrorWhileAddingEntity));
                }
            }

            try
            {
                _categoryDal.Add(category);
                var addedCategory = _categoryDal.Get(c => c.CategoryName == category.CategoryName);
                var subCategory   = new SubCategory
                {
                    CategoryId    = mainCategoryId,
                    SubCategoryId = addedCategory.CategoryId
                };
                _subCategoryDal.Add(subCategory);
                return(new SuccessResult());
            }
            catch (Exception e)
            {
                return(new ErrorResult(Messages.ErrorWhileAddingEntity));
            }
        }
Пример #2
0
        public void Add(Category category)
        {
            if (category == null ||
                String.IsNullOrEmpty(category.Name) ||
                String.IsNullOrEmpty(category.Description))
            {
                return;
            }

            _categoryDal.Add(category);
        }
Пример #3
0
 public IResult Add(Category category)
 {
     //İş Kuralları
     //...
     _categoryDal.Add(category);
     return(new SuccessResult(Messages.CategoryAdded));
 }
        public IResult Add(Category category)
        {
            //ValidationTool.Validate(new CategoryValidator(), category);

            _categoryDal.Add(category);
            return(new SuccessDataResult <Category>(Messages.DataAdded));
        }
Пример #5
0
 public IResult Add(Category category)
 {
     _validation = new Validation <CategoryValidator>();
     _validation.Validate(category);
     _categoryDal.Add(category);
     return(new SuccessResult());
 }
Пример #6
0
        public ResultMessage Add(Category entity)
        {
            ResultMessage result = new ResultMessage();

            result.IsSuccess = false;

            if (entity.Name.Length == 0)
            {
                result.Message = "Kategori Adı Belirtmelisiniz";
                return(result);
            }

            if (entity.Name.Length > 50)
            {
                result.Message = "Kategori Adı daha kısa olmalıdır";
                return(result);
            }

            try
            {
                _categoryDal.Add(entity);
                result.IsSuccess = true;
            }
            catch (Exception e)
            {
                result.Message = string.Format("Bir hata oluştu: {0}", e.Message);
                return(result);
            }

            return(result);
        }
Пример #7
0
        public ResultMessage Add(Category entity)
        {
            ResultMessage result = new ResultMessage();

            result.isSuccess = false;

            if (entity.Name.Length == 0)
            {
                result.Message = "Kategori Adı Belirtmelisiniz";
                return(result);
            }
            if (entity.Name.Length == 50)
            {
                result.Message = "Kategori Adı için fazla karakter girdiniz.";
                return(result);
            }
            try
            {
                _categoryDal.Add(entity);
                result.isSuccess = true;
            }
            catch (Exception e)
            {
                result.Message = "Bir Hata Oluştu";
                return(result);
            }
            return(result);
        }
Пример #8
0
 public IResult Add(Category category)
 {
     category.CreateDate = DateTime.Now;
     category.Active     = true;
     _categoryDal.Add(category);
     return(new SuccessResult(BusinessMessages.CategoryAdded));
 }
Пример #9
0
        public IResult Add(CategoryCreateUpdateDto categoryDto)
        {
            var category = _mapper.Map <Category>(categoryDto);

            return(_categoryDal.Add(category)
                ? new SuccessResult("Category created.")
                : new ErrorResult("Category cannot created!"));
        }
Пример #10
0
        public void Add(Category category)
        {
            ValidationTool.Load(new CategoryRules(), category);



            _categoryDal.Add(category);
        }
Пример #11
0
        public IResult Add(Category category)
        {
            ValidationTool.Validate(new CategoryValidator(), category);

            _categoryDal.Add(category);

            return(new SuccessResult(Messages.CategoryAdded));
        }
Пример #12
0
 public IResult Add(Category category)
 {
     if (category.CategoryName.Length < 3)
     {
         return(new ErrorResult(Messages.NameInvalid));
     }
     _categoryDal.Add(category);
     return(new SuccessResult());
 }
Пример #13
0
        public void Add(Category category)
        {
            if (category.CategoryName.Length < 2)
            {
                throw new Exception("Kategori ismi min 2 karakter olmalıdır");
            }

            _categoryDal.Add(category);
        }
Пример #14
0
 public IActionResult Create(Category category)
 {
     if (ModelState.IsValid)
     {
         _categoryDal.Add(category);
         return(RedirectToAction("Index", "Categories"));
     }
     return(View(category));
 }
Пример #15
0
        public void Add(CategoryDto data)
        {
            var category = new Category
            {
                Name        = data.Name,
                Description = data.Description
            };

            _categoryDal.Add(category);
        }
Пример #16
0
        public IResult Add(Category category)
        {
            if (category.CategoryName.Length > 5)
            {
                return(new ErrorResult("Kategori adı en az 5 karakter olmalıdır"));
            }

            _categoryDal.Add(category);
            return(new SuccessResult(Messages.CategoryAdded));
        }
Пример #17
0
        public bool Add(Category category)
        {
            if (string.IsNullOrEmpty(category.CategoryName))
            {
                return(false);
            }

            categoryDal.Add(category);
            return(true);
        }
Пример #18
0
        //[SecuredOperation("admin,moderator")]
        public IResult GetCategoryAdd(Category category)
        {
            var result = BusinessRules.Run(CheckCategoryNameExists(category.CategoryName));

            if (result != null)
            {
                return(result);
            }
            _categoryDal.Add(category);
            return(new SuccessResult(Messages.CategoryAdded));
        }
Пример #19
0
        public IResult Add(Category category)
        {
            var result = BusinessRules.Run(ExampleBusinessRule());

            if (result != null)
            {
                return(result);
            }
            _categoryDal.Add(category);
            return(new SuccessResult(Messages.CategoryAdded));
        }
Пример #20
0
        public bool Add(Category category)
        {
            bool result = _categoryDal.Add(category);

            if (result)
            {
                return(true);
            }

            return(false);
        }
Пример #21
0
        public Category Add(Category category, HttpPostedFileBase Image)
        {
            if (Image != null)
            {
                ImageDetail imagePath = _fileUploadService.ThumbImageSave(Image, "Category", 225, 225);
                category.Image      = imagePath.Image;
                category.ThumbImage = imagePath.ThumbImage;
            }

            return(_categoryDal.Add(category));
        }
Пример #22
0
 public void AddCategory(Category category)
 {
     if (category != null)
     {
         _categoryDal.Add(category);
     }
     else
     {
         throw new Exception("Hata oldu");
     }
 }
Пример #23
0
 public IDataResult <Category> Add(Category category)
 {
     if (category != null)
     {
         return(new SuccessDataResult <Category>(_categoryDal.Add(category), "Category added!"));
     }
     else
     {
         return(new ErrorDataResult <Category>(category, "Category could not be added!"));
     }
 }
Пример #24
0
        public IResult Add(Category category)
        {
            var result = _categoryDal.Get(c => c.CategoryName == category.CategoryName);

            if (result == null)
            {
                _categoryDal.Add(category);
                return(new SuccessResult(Messages.Categories.Add(category.CategoryName)));
            }
            return(new ErrorResult(Messages.Categories.Exists(category.CategoryName)));
        }
Пример #25
0
 public IResult Add(Category category)
 {
     if (category.CategoryName.Length > 2)
     {
         _categoryDal.Add(category);
         return new SuccessResult(Messages.CategoryAdded);
     }
     else
     {
         return new ErrorResult(Messages.CategoryNameInvalid);
     }
 }
Пример #26
0
        public IResult Add(Category category)
        {
            IResult result = BusinessRules.Run(CheckIfCategoryNameExists(category.CategoryName));

            if (result != null)
            {
                return(new ErrorResult());
            }

            _categoryDal.Add(category);
            return(new SuccessResult(Messages.Categories.Add(category.CategoryName)));
        }
 public IResult Add(Category entity)
 {
     try
     {
         _categoryDal.Add(entity);
         return(new SuccessResult("Category eklendi"));
     }
     catch (Exception ex)
     {
         return(new ErrorResult(ex.ToString()));
     }
 }
Пример #28
0
 public IResult Add(Category category)
 {
     try
     {
         _categoryDal.Add(category);
         return(new SuccessResult(Messages.SuccessAdded));
     }
     catch (Exception)
     {
         return(new ErrorResult(Messages.ErrorAdded));
     }
 }
Пример #29
0
        public IResult Add(Category category)
        {
            IResult result = BusinessRules.Run(CheckIfCategoryNameExists(category.CategoryName));

            if (!(result is null))
            {
                return(result);
            }

            _categoryDal.Add(category);
            return(new SuccessResult(Messages.CategoryAdded));
        }
 public Category Insert(CategoryDto categoryDto)
 {
     if (!IsCategoryCheck(categoryDto.Title))
     {
         var category = new Category()
         {
             Description = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(categoryDto.Description),
             Title       = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(categoryDto.Title)
         };
         return(_categoryDal.Add(category));
     }
     throw new Exception("Girdiğiniz Kategori bilgilerini kontrol ediniz");
 }