Exemple #1
0
 public async Task <Category> Create(CreateCategoryItemInfo info)
 {
     return(await categoryDao.Create(info));
 }
Exemple #2
0
        public void create(Category objCategory)
        {
            Category objCategoryAux = new Category();
            bool     verification   = true;

            string code = objCategory.IdCategory;

            if (code == null || code.Trim().Equals(""))
            {
                objCategory.State = 10;
                return;
            }
            else
            {
                code         = objCategory.IdCategory.Trim();
                verification = code.Length > 0 && code.Length <= 5;
                if (!verification)
                {
                    objCategory.State = 1;
                    return;
                }
            }

            string name = objCategory.Name;

            if (name == null || name.Equals(""))
            {
                objCategory.State = 20;
                return;
            }
            else
            {
                name         = objCategory.Name.Trim();
                verification = name.Length > 0 && name.Length <= 30;
                if (!verification)
                {
                    objCategory.State = 2;
                    return;
                }
            }

            string description = objCategory.Description;

            if (description == null || description.Trim().Equals(""))
            {
                objCategory.State = 30;
                return;
            }
            else
            {
                description  = objCategory.Description.Trim();
                verification = description.Length > 0 && description.Length <= 50;
                if (!verification)
                {
                    objCategory.State = 3;
                    return;
                }
            }


            objCategoryAux.IdCategory = objCategory.IdCategory;
            verification = !objCategoryDao.Find(objCategoryAux);
            if (!verification)
            {
                objCategory.State = 8;
                return;
            }

            //verificar o nome
            objCategoryAux.Name = objCategory.Name;
            verification        = !objCategoryDao.FindCat(objCategoryAux);
            if (!verification)
            {
                objCategory.State = 16;
                return;
            }

            objCategory.State = 99;
            objCategoryDao.Create(objCategory);
            return;
        }