Beispiel #1
0
        //add a google_value object to db
        public static bool deleteGoogleValue(string id)
        {
            SwapDbConnection db         = new SwapDbConnection();
            google_value     google_obj = db.google_value.Where(x => x.google_value_id == id).FirstOrDefault();

            if (google_obj == null)
            {
                return(false);
            }
            db.google_value.Remove(google_obj);
            db.SaveChanges();
            return(true);
        }
Beispiel #2
0
        //add a google_value object to db
        public static google_value AddGoogleValue(string value)
        {
            SwapDbConnection db         = new SwapDbConnection();
            google_value     google_obj = new google_value()
            {
                google_value_id = IdService.generateID("google_value_id"),
                value           = value
            };

            db.google_value.Add(google_obj);
            db.SaveChanges();
            return(google_obj);
        }
Beispiel #3
0
        public void DeleteGoogleValueSuccess()
        {
            var config     = new HttpConfiguration();
            var request    = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/user/44300");
            var route      = config.Routes.MapHttpRoute("Default", "api/{controller}/DeleteGoogleValue/{id}");
            var controller = new GoogleValueController
            {
                Request = request,
            };

            controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
            SwapDbConnection db   = new SwapDbConnection();
            google_value     test = db.google_value.Where(x => x.value == "unit test").FirstOrDefault();

            Assert.AreEqual(controller.DeleteGoogleValue(test.google_value_id).StatusCode, HttpStatusCode.OK);
        }