Esempio n. 1
0
        public bool ValidateUpdate(CategoryEntity CategoryEntity)
        {
            bool IsValid = true;

            if (UnitOfWork.CategoryRepository.Get(CategoryEntity.Id) == null)
            {
                CategoryEntity.AddError(nameof(CategoryEntity.Id), "Item doesn't existed.");
            }
            if (string.IsNullOrEmpty(CategoryEntity.Code))
            {
                CategoryEntity.AddError(nameof(CategoryEntity.Code), "Must fill data.");
            }
            if (CategoryEntity.Errors.Count > 0)
            {
                IsValid = false;
            }
            foreach (CategoryNameEntity CategoryNameEntity in CategoryEntity.CategoryNameEntities)
            {
                if (string.IsNullOrEmpty(CategoryNameEntity.Name))
                {
                    CategoryNameEntity.AddError(nameof(CategoryNameEntity.Name), "Must fill data.");
                }
                if (CategoryNameEntity.Errors.Count > 0)
                {
                    IsValid = false;
                }
            }
            return(IsValid);
        }
Esempio n. 2
0
        public bool ValidateCreate(CategoryEntity CategoryEntity)
        {
            bool IsValid = true;

            if (string.IsNullOrEmpty(CategoryEntity.Code))
            {
                CategoryEntity.AddError(nameof(CategoryEntity.Code), "Must fill data.");
            }
            if (CategoryEntity.Errors.Count > 0)
            {
                IsValid = false;
            }
            foreach (CategoryNameEntity CategoryNameEntity in CategoryEntity.CategoryNameEntities)
            {
                if (string.IsNullOrEmpty(CategoryNameEntity.Name))
                {
                    CategoryNameEntity.AddError(nameof(CategoryNameEntity.Name), "Must fill data.");
                }
                if (CategoryNameEntity.Errors.Count > 0)
                {
                    IsValid = false;
                }
            }
            return(IsValid);
        }