public void Then_The_Fields_Are_Correctly_Mapped(Domain.Entities.Location source)
        {
            //Arrange & Act
            var actual = (SuggestedLocation)source;

            //Assert
            actual.Should().BeEquivalentTo(source, options => options.ExcludingMissingMembers());
        }
예제 #2
0
 private LocationModel MapLocation(Domain.Entities.Location location)
 {
     return(new LocationModel
     {
         Latitude = location.Latitude,
         Longitude = location.Longitude,
         Address = MapAddress(location.Address)
     });
 }
        public async Task Create(LocationDto dto)
        {
            var location = new Domain.Entities.Location
            {
                Description = dto.Description,
                ErasedState = false,
                ProvinceId  = dto.ProvinceId
            };

            await _locationRepository.Create(location);
        }
예제 #4
0
 public static Models.Location Map(this Domain.Entities.Location location)
 {
     return(new Models.Location
     {
         LocationId = location.LocationId,
         LocationName = location.LocationName,
         //LocationDescription = location.LocationDescription,
         LocationCode = location.LocationCode,
         City = location.City,
         Province = location.Province,
         PostalCode = location.PostalCode,
         //ZipCode
     });
 }
예제 #5
0
        public async Task Then_The_Service_Is_Called(
            GetLocationQuery query,
            Domain.Entities.Location location,
            [Frozen] Mock <ILocationService> service,
            GetLocationQueryHandler handler)
        {
            //Arrange
            service.Setup(x => x.GetLocationsByLocationAuthorityName(query.LocationName, query.AuthorityName)).ReturnsAsync(location);

            //Act
            var actual = await handler.Handle(query, CancellationToken.None);

            //Assert
            actual.Location.Should().BeEquivalentTo(location);
        }
        public async Task Then_The_Repository_Is_Called_With_The_Names(
            string authorityName,
            string locationName,
            Domain.Entities.Location location,
            [Frozen] Mock <ILocationRepository> repository,
            LocationService service
            )
        {
            //Arrange
            repository.Setup(x => x.GetByLocationAndAuthorityName(locationName, authorityName))
            .ReturnsAsync(location);

            //Act
            var actual = await service.GetLocationsByLocationAuthorityName(locationName, authorityName);

            //Assert
            actual.Should().BeEquivalentTo(location);
        }
예제 #7
0
            public async Task <CreateLocationItemDto> Handle(CreateLocationItemCommand request, CancellationToken cancellationToken)
            {
                var entity = new Domain.Entities.Location()
                {
                    Name        = request.Name,
                    IsEnabled   = request.IsEnabled,
                    OpeningTime = request.OpeningTime,
                    ClosingTime = request.ClosingTime,
                    Description = request.Description,
                    Address     = request.Address,
                };
                await context.Locations.AddAsync(entity);


                if (request.InstructorLists.Count > 0)
                {
                    var getInstructorListDbQuery = context.Instructor
                                                   .Include(i => i.LocationInstructors)
                                                   .OrderBy(i => i.FirstName)
                                                   .Where(i => request.InstructorLists.Contains(i.Id));
                    var instructorEntities = await getInstructorListDbQuery.ToListAsync();

                    if (instructorEntities.Count != request.InstructorLists.Count)
                    {
                        throw new EntityListCountMismatchException <Domain.Entities.Instructor>(instructorEntities, request.InstructorLists);
                    }
                    foreach (var instructorEntity in instructorEntities)
                    {
                        var li = new LocationInstructor
                        {
                            Instructor = instructorEntity,
                            Location   = entity,
                        };
                        entity.LocationInstructors.Add(li);
                    }
                }

                await context.SaveChangesAsync(cancellationToken);

                return(new CreateLocationItemDto
                {
                    Id = entity.Id
                });
            }
예제 #8
0
        public void Arrange()
        {
            _expectedLocation = new Domain.Entities.Location
            {
                Id                 = 4,
                LocationName       = "different",
                LocalAuthorityName = "test1"
            };
            _items = new List <Domain.Entities.Location>
            {
                new Domain.Entities.Location
                {
                    Id                 = 1,
                    LocationName       = "testing",
                    LocalAuthorityName = "test1"
                },
                new Domain.Entities.Location
                {
                    Id                 = 2,
                    LocationName       = "test",
                    LocalAuthorityName = "test1"
                },
                new Domain.Entities.Location
                {
                    Id                 = 3,
                    LocationName       = "retest",
                    LocalAuthorityName = "test1"
                },
                _expectedLocation
            };

            _locationDataContext = new Mock <ILocationDataContext>();
            _locationDataContext.Setup(x => x.Locations).ReturnsDbSet(_items);


            _locationRepository = new Data.Repository.LocationRepository(_locationDataContext.Object);
        }
예제 #9
0
        public static Entities.User UserDTO(Result item)
        {
            var email       = new Email(item.email);
            var coordinates = new Domain.Entities.ValueObjects.Coordinates
            {
                Latitude  = item.location.coordinates.latitude,
                Longitude = item.location.coordinates.longitude
            };

            var street = new Domain.Entities.ValueObjects.Street
            {
                Name   = item.location.street.name,
                Number = item.location.street.number
            };

            var timezone = new Domain.Entities.ValueObjects.Timezone
            {
                Description = item.location.timezone.description,
                Offset      = item.location.timezone.offset
            };

            var location = new Domain.Entities.Location
            {
                City        = item.location.city,
                Coordinates = coordinates,
                Country     = item.location.country,
                Postcode    = item.location.postcode,
                State       = item.location.state,
                Street      = street,
                Timezone    = timezone
            };

            var phoneNumber = new Domain.Entities.PhoneNumber(item.phone);

            var name = new Domain.Entities.ValueObjects.Name(item.name.title, item.name.first, item.name.last);

            var login = new Domain.Entities.ValueObjects.Login
            {
                Id       = item.login.uuid,
                Md5      = item.login.md5,
                Password = item.login.password,
                Salt     = item.login.salt,
                Sha1     = item.login.sha1,
                Sha256   = item.login.sha256,
                Username = item.login.username
            };

            var dob = new Domain.Entities.ValueObjects.Dob
            {
                Age  = item.dob.age,
                Date = item.dob.date
            };

            var registered = new Domain.Entities.ValueObjects.Registered
            {
                Age  = item.registered.age,
                Date = item.registered.date
            };

            var image = new Image(item.picture.thumbnail);

            var user = new User
            {
                Cell       = item.cell,
                Dob        = dob,
                Email      = email,
                Gender     = item.gender,
                Status     = RandomStatus.Published,
                Imported_t = DateTime.Now,
                Location   = location,
                Login      = login,
                Name       = name,
                Nat        = item.nat,
                Phone      = phoneNumber,
                Picture    = image,
                Registered = registered
            };

            return(user);
        }