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"); } }
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"); } }
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"); } }
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 })); } }