Example #1
0
        public void UT_Admin_CreateCategory_NameInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateCategoryV1(repo);

            if (service.Exec(null, new NewCategoryData {
                Name = ""
            }))
            {
                Assert.Fail("CreateCategory // Name empty accepted");
            }
        }
Example #2
0
        public void UT_Admin_CreateCategory_CategoryExist()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateCategoryV1(repo);

            if (service.Exec(null, new NewCategoryData {
                Name = "xxx"
            }))
            {
                Assert.Fail("CreateCategory // Existing user cannot create same account");
            }
        }
Example #3
0
        public void UT_Admin_CreateCategory_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateCategoryV1(repo);

            if (!service.Exec(null, new NewCategoryData {
                Name = "pass"
            }))
            {
                Assert.Fail("CreateCategory // Not existing user should create account");
            }
        }
Example #4
0
        public ActionResult <string> CreateCategory([FromBody] NewCategoryData obj)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminCreateCategoryV1(repository);

                    if (!service.Exec(db, obj))
                    {
                        return(BadRequest(service.Error));
                    }

                    return(Ok(new { Id = service.IdCreated }));
                }
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new ServiceError {
                    DebugInfo = ex.ToString(), Message = _defaultError
                }));
            }
        }