public IActionResult Delete(int?Id)
 {
     if (HttpContext.Session.GetString("ID") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (Id == null)
         {
             //Error
             return(RedirectToAction("NotFoundPage", "Home"));
         }
         else
         {
             Region model = regionRepository.GetRegion(Id);
             return(View(model));
         }
     }
 }
        public async Task IntegrationTestGetRegion_WithInvalidRegionId()
        {
            // Arrange
            RegionRepository repository     = new RegionRepository(DevelopmentStorageAccountConnectionString, String.Empty);
            Guid             dummySessionId = new Guid("74720766-452A-40AD-8A61-FEF07E8573C9");
            Guid             dummyRegionId  = new Guid("DE167712-0CE6-455C-83EA-CB2A6936F1BE");

            TableClient.SetupSessionDataTable(dummySessionId);

            // Act
            IRegionData regionData = await repository.GetRegion(dummySessionId, dummyRegionId);

            // Assert
            Assert.IsNull(regionData);
        }
示例#3
0
        public void GetRegion_GivenANameOnNonEmptyDatabase_ReturnsTheRegionRecord()
        {
            // arrange
            List <Region> data     = new List <Region>();
            Region        expected = new Region {
                ID = 1, Continent = "North America", Country = "Canada", Name = "Eastern Canada", Provinces = null
            };

            data.Add(expected);
            Mock <DbSet <Region> > mockSet     = EntityMockFactory.CreateSet(data.AsQueryable());
            Mock <LocationDb>      mockContext = new Mock <LocationDb>();

            mockContext.Setup(c => c.Regions).Returns(mockSet.Object);
            RegionRepository sut = new RegionRepository(mockContext.Object);

            // act
            Region actual = sut.GetRegion("Eastern Canada");

            // assert
            Assert.IsTrue(expected.Equals(actual));
        }
        public async Task IntegrationTestGetRegion()
        {
            // Arrange
            RegionRepository repository       = new RegionRepository(DevelopmentStorageAccountConnectionString, String.Empty);
            Guid             dummySessionId   = new Guid("74720766-452A-40AD-8A61-FEF07E8573C9");
            Guid             dummyRegionId    = new Guid("89B6BDF0-83B7-42F1-B216-7DFFB8D11EA2");
            Guid             dummyContinentId = new Guid("DE167712-0CE6-455C-83EA-CB2A6936F1BE");
            List <Guid>      dummyConnections = new List <Guid> {
                new Guid("0533203F-13F2-4863-B528-17F53D279E19"), new Guid("4A9779D0-0727-4AD9-AD66-17AE9AF9BE02")
            };

            TableClient.SetupSessionDataTable(dummySessionId);
            using (IBatchOperationHandle batchOperation = new BatchOperationHandle(SessionRepository.GetTableForSessionData(TableClient, dummySessionId)))
            {
                repository.CreateRegion(batchOperation, dummySessionId, dummyRegionId, dummyContinentId, "DummyRegion", dummyConnections, 0);
            }

            // Act
            IRegionData regionData = await repository.GetRegion(dummySessionId, dummyRegionId);

            // Assert
            Assert.IsNotNull(regionData);
            Assert.AreEqual(dummySessionId, regionData.SessionId);
        }
 public IActionResult getRegion(int id)
 {
     return(Ok(regionRepository.GetRegion(id)));
 }