Exemplo n.º 1
0
        public void DeleteResource_GetNull()
        {
            var resourceRepository = new ResourceRepository(_resourceContext);
            var resource1          = resourceRepository.Get("key1", "part1");

            resourceRepository.Delete(resource1);

            resourceRepository.Get("key1", "part1").ShouldBeNull();
        }
Exemplo n.º 2
0
        public ResourceOutputDto GetForm(string keyValue)
        {
            var id = Convert.ToInt64(keyValue);
            ResourceOutputDto resourceOutputDto = new ResourceOutputDto();
            Resource          organize          = resourceRepository.Get(id);

            AutoMapper.Mapper.Map <Resource, ResourceOutputDto>(organize, resourceOutputDto);
            return(resourceOutputDto);
        }
Exemplo n.º 3
0
        public void Get_WithValidKeyAndPartitionWithTwoResourcesInDb_GetOneResource()
        {
            var repository = new ResourceRepository(_resourceContext);
            var resource   = repository.Get("key3", "part2");

            resource.ShouldNotBe(null);
            resource.Key.ShouldBe("key3");
            resource.Partition.ShouldBe("part2");
        }
Exemplo n.º 4
0
 public void DeleteResource(int resourceID)
 {
     try
     {
         ResourceRepository resourceRepo = new ResourceRepository();
         var r = resourceRepo.Get(resourceID);
         resourceRepo.Delete(r);
         GlobalUnitOfWork.Commit();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
        public void UpdateTwoValuesOfSamePartitionGetTwoResourcesBack()
        {
            var resourceRepository = new ResourceRepository(_resourceContext);
            var resource1          = resourceRepository.Get("key1", "part1");

            resource1.Value = "value4";
            resourceRepository.Update(resource1);

            var resource2 = resourceRepository.Get("key2", "part2");

            resource2.Value = "value5";
            resourceRepository.Update(resource2);

            var item1 = resourceRepository.Get("key1", "part1");

            item1.ShouldNotBeNull();
            item1.Value.ShouldBe("value4");

            var item2 = resourceRepository.Get("key2", "part2");

            item2.ShouldNotBeNull();
            item2.Value.ShouldBe("value5");
        }
Exemplo n.º 6
0
        public Resource GetResourceById(int id)
        {
            Resource result;

            try
            {
                ResourceRepository resourceRepo = new ResourceRepository();
                result = resourceRepo.Get(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Exemplo n.º 7
0
        public void UpdateResource(Resource resource)
        {
            try
            {
                ResourceRepository resourceRepo = new ResourceRepository();

                var repo = resourceRepo.Get(resource.ResourceID);

                if (repo == null)
                {
                    resourceRepo.Add(resource);
                }
                else
                {
                    resourceRepo.Update(resource);
                }
            }
            catch (Exception ex) {
                throw ex;
            }

            GlobalUnitOfWork.Commit();
        }
 public Resource GetResource(int id) => _ResourceRepository.Get <Resource>(DataContext, id);
Exemplo n.º 9
0
 internal Resource Get(int id)
 => _resourceRepository.Get(id);