public ActionResult Update(CabEntity cab)
        {
            int id = cab.LocationId;

            CabRepository.Update(cab);
            return(RedirectToAction("DataPassing"));
        }
        public ActionResult DataPassing()
        {
            IEnumerable <CabEntity> cab = CabRepository.GetLocation();

            ViewBag.CabDetails = cab;
            ViewData["cab"]    = cab;
            TempData["cab"]    = cab;
            return(Redirect("Display"));
        }
        public ActionResult CreateLocation()
        {
            CabEntity cab = new CabEntity();

            UpdateModel(cab);
            //int locationId=cab[
            CabRepository.Add(cab);
            TempData["Result"] = "Added successfully";
            return(RedirectToAction("DataPassing"));
        }
Ejemplo n.º 4
0
        public async Task WhenItemDoesNotExists_ShouldThrowKeyNotFoundException()
        {
            // Arrange
            var cabId     = _fixture.Create <Id <Cab> >();
            var dbContext = new DispatchingDbContextBuilder()
                            .Build();

            // Act
            using (dbContext)
            {
                var         sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper);
                Func <Task> act = async() => await sut.Get(cabId);

                // Assert
                act.Should().Throw <KeyNotFoundException>();
            }
        }
Ejemplo n.º 5
0
        public async Task Initialize()
        {
            _databaseName = _fixture.Create <string>();

            // Arrange
            _cab       = _fixture.Create <Cab>();
            _mappedCab = _fixture.Create <PersistenceModel.Cab>();

            var persistenceModelMapper = Substitute.For <IMapToDomainModel <PersistenceModel.Cab, Cab> >();
            var domainModelMapper      = CreateDomainModelMapper(_mappedCab);

            // Act
            using (var dbContext = CreateDbContext())
            {
                var sut = new CabRepository(dbContext, domainModelMapper, persistenceModelMapper);
                await sut.Update(_cab);
            }
        }
Ejemplo n.º 6
0
        public async Task WhenData_ShouldMapToDomainModel()
        {
            // Arrange
            var dbContext = new DispatchingDbContextBuilder(_fixture.Create <string>())
                            .WithCustomerLocation(_location)
                            .WithCab(_nearestCabId, _distance)
                            .Build();

            // Act
            using (dbContext)
            {
                var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper);
                await sut.GetNearestAvailableCab(_location);

                // Assert
                _persistenceModelMapper
                .Received(1)
                .Map(Arg.Is(dbContext.Cabs.Single()));
            }
        }
Ejemplo n.º 7
0
        public async Task WhenItemExists_ShouldMapEntityIntoDomainModel()
        {
            // Arrange
            var cab       = _fixture.Create <PersistenceModel.Cab>();
            var cabId     = new Id <Cab>(cab.Id);
            var dbContext = new DispatchingDbContextBuilder()
                            .WithCab(cab)
                            .Build();

            // Act
            using (dbContext)
            {
                var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper);
                await sut.Get(cabId);

                // Assert
                _persistenceModelMapper
                .Received(1)
                .Map(Arg.Is <PersistenceModel.Cab>(x => x.Id == cab.Id));
            }
        }
Ejemplo n.º 8
0
        public async Task WhenLocation_ShouldReturnNearestCab()
        {
            // Arrange
            var dbContext = new DispatchingDbContextBuilder()
                            .WithCustomerLocation(_location)
                            .WithCab(_nearestCabId, _distance)
                            .WithCab(_fixture.Create <Guid>(), _distance + _fixture.Create <decimal>())
                            .Build();

            // Act
            using (dbContext)
            {
                var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper);
                await sut.GetNearestAvailableCab(_location);

                // Assert
                _persistenceModelMapper
                .Received(1)
                .Map(Arg.Is <PersistenceModel.Cab>(x => x.Id == _nearestCabId));
            }
        }
Ejemplo n.º 9
0
        public async Task WhenLocation_ShouldReturnResultFromPersistenceModelMapper()
        {
            // Arrange
            var dbContext = new DispatchingDbContextBuilder()
                            .WithCustomerLocation(_location)
                            .WithCab(_nearestCabId, _distance)
                            .Build();

            var expected = _fixture.Create <Cab>();

            _persistenceModelMapper
            .Map(Arg.Any <PersistenceModel.Cab>())
            .Returns(expected);

            // Act
            using (dbContext)
            {
                var sut    = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper);
                var actual = await sut.GetNearestAvailableCab(_location);

                // Assert
                actual.Should().Be(expected);
            }
        }
 public ActionResult Delete(int id)
 {
     CabRepository.Delete(id);
     TempData["Result"] = "Deleted Successfully";
     return(RedirectToAction("DataPassing"));
 }
        public ActionResult Edit([Bind(Exclude = "LocationId")] int id)
        {
            CabEntity cab = CabRepository.GetLocationById(id);

            return(View(cab));
        }
        // GET: Cab
        public ActionResult Index()
        {
            IEnumerable <CabEntity> cabEntities = CabRepository.GetLocation();

            return(View(cabEntities));
        }