//get google value by id public static googleValueDto GetGoogleValueByid(string id) { SwapDbConnection db = new SwapDbConnection(); googleValueDto googleDto = db.google_value .Select(x => new googleValueDto() { google_id = x.google_value_id, value = x.value }) .FirstOrDefault(x => x.google_id == id); return(googleDto); }
public void AddGoogleValueInternalServerError() { var config = new HttpConfiguration(); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/user/44300"); var route = config.Routes.MapHttpRoute("Default", "api/{controller}/AddGoogleValue/{id}"); var controller = new GoogleValueController { Request = request, }; controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; var test = new googleValueDto(); Assert.AreEqual(controller.AddGoogleValue(test).StatusCode, HttpStatusCode.InternalServerError); }
public HttpResponseMessage AddGoogleValue([FromBody] googleValueDto value) { try { if (value != null) { return(Request.CreateResponse(HttpStatusCode.OK, GoogleValueService.AddGoogleValue(value.value))); } return(Request.CreateResponse(HttpStatusCode.BadRequest, "there is no value in the body")); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e)); } }