public IActionResult Index([FromHeader] string sendJson, int?id) { ViewBag.Active = "Resources"; string sqlString = "SELECT * FROM Resource"; if (id.HasValue) { sqlString += " WHERE Id = " + id.Value; var model = ResourceDBConnector.GetResources(Constants.DATA_SOURCE, sqlString); var singleEvent = model.Count > 0 ? model.First() : new Resource(); return(sendJson != null && sendJson.Equals("True") ? Json(singleEvent) : (IActionResult)View(singleEvent)); } var eventList = ResourceDBConnector.GetResources(Constants.DATA_SOURCE, sqlString); return(sendJson != null && sendJson.Equals("True") ? Json(eventList) : (IActionResult)View(eventList)); }
public void TestInsert() { List <Resource> resources = ResourceDBConnector.GetResources(dataSource, "SELECT * FROM Resource"); Assert.NotNull(resources); int count = resources.Count; Resource resource = new Resource(); resource.Description = "Test"; resource.Link = "some link"; resource.Title = "Test Resource"; resource.ProviderName = "Unit Test"; Assert.True(ResourceDBConnector.Create(dataSource, resource)); resources = ResourceDBConnector.GetResources(dataSource, "SELECT * FROM Resource"); Assert.NotNull(resources); Assert.Equal(count + 1, resources.Count); }
public void TestRetrieveAll() { List <Resource> resources = ResourceDBConnector.GetResources(dataSource, "SELECT * FROM Resource"); Assert.NotNull(resources); }