Ejemplo n.º 1
0
        public void TestUpdate()
        {
            Resource resource = new Resource();

            resource.Description  = "Test";
            resource.Link         = "some link";
            resource.Title        = "Test Resource";
            resource.ProviderName = "Unit Test";
            Assert.True(ResourceDBConnector.Update(dataSource, resource));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public void TestRetrieveSpecific()
        {
            Resource resource = ResourceDBConnector.GetResource(dataSource, 2);

            Assert.NotNull(resource);
        }
Ejemplo n.º 5
0
        public void TestRetrieveAll()
        {
            List <Resource> resources = ResourceDBConnector.GetResources(dataSource, "SELECT * FROM Resource");

            Assert.NotNull(resources);
        }
Ejemplo n.º 6
0
 public IActionResult Delete(int id)
 {
     ResourceDBConnector.Delete(Constants.DATA_SOURCE, id);
     return(Redirect("/Resources"));
 }
Ejemplo n.º 7
0
 public IActionResult Edit(int id)
 {
     return(View(ResourceDBConnector.GetResource(Constants.DATA_SOURCE, id)));
 }
Ejemplo n.º 8
0
        public IActionResult Edit(Resource resource, int id)
        {
            ResourceDBConnector.Update(Constants.DATA_SOURCE, resource);

            return(Redirect("/Resources"));
        }
Ejemplo n.º 9
0
        public IActionResult Add(Resource resource)
        {
            ResourceDBConnector.Create(Constants.DATA_SOURCE, resource);

            return(Redirect("/Resources"));
        }