Esempio n. 1
0
        public void UT_Admin_CreateCategory_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateSubCategoryV1(repo);

            if (!service.Exec(null, new NewSubCategoryData {
                ProductCategoryID = 1, Name = "xxx"
            }))
            {
                Assert.Fail("CreateSubCategory // ok not passed");
            }
        }
Esempio n. 2
0
        public void UT_Admin_CreateSubCategory_NameInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateSubCategoryV1(repo);

            if (service.Exec(null, new NewSubCategoryData {
                ProductCategoryID = 1, Name = ""
            }))
            {
                Assert.Fail("CreateSubCategory // Name empty accepted");
            }
        }
Esempio n. 3
0
        public ActionResult <string> CreateSubCategory([FromBody] NewSubCategoryData obj)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminCreateSubCategoryV1(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
                }));
            }
        }