示例#1
0
        public void UT_Admin_product()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminProductV1(repo);

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

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

            if (resp.Name != "test")
            {
                Assert.Fail("product // fail 2");
            }
        }
示例#2
0
        public ActionResult <string> Product(long id)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminProductV1(repository);
                    var resp    = service.Exec(db, id);

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