Beispiel #1
0
        public void UT_Admin_category()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCategoryV1(repo);

            var resp = service.Exec(null, new AuthenticatedUser(), 1);

            if (resp.Id != 1)
            {
                Assert.Fail("category // fail 1");
            }

            if (resp.Name != "test")
            {
                Assert.Fail("category // fail 2");
            }
        }
Beispiel #2
0
        public ActionResult <string> Category(long id)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminCategoryV1(repository);
                    var resp    = service.Exec(db, GetCurrentAuthenticatedUser(), id);

                    return(Ok(JsonConvert.SerializeObject(resp)));
                }
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new ServiceError {
                    DebugInfo = ex.ToString(), Message = _defaultError
                }));
            }
        }