Beispiel #1
0
        public async Task <List <ReadRelationDTO> > GetAllRelations(EntityDTO input)
        {
            List <Relation> relations = await _relationRepository.GetAll()
                                        .Include(z => z.Location)
                                        .Where(z => z.IsActive == true && z.Location.Id == input.Id)
                                        .ToListAsync();

            List <ReadRelationDTO> result = new List <ReadRelationDTO>();

            foreach (Relation item in relations)
            {
                ReadRelationDTO dto = new ReadRelationDTO
                {
                    Id          = item.Id,
                    CreatedTime = item.CreatedTime,
                    ArtifacName = item.Artifact.Name,
                    BeaconName  = item.Beacon.Name,
                    ContentName = item.Content.Name
                };
                dto.Proximity = GetEnumString(item.Proximity);

                result.Add(dto);
            }
            return(result);
        }
Beispiel #2
0
        //LocationId
        public async Task <List <ReadArtifactDTO> > GetAllArtifacts(EntityDTO input)
        {
            var artifacts = await _artifactRepository
                            .GetAll()
                            .Include(x => x.Location)
                            .Include(x => x.Room)
                            .ThenInclude(x => x.Floor)
                            .ThenInclude(x => x.Building)
                            .Where(x => x.IsActive && x.Location.Id == input.Id)
                            .ToListAsync();

            List <ReadArtifactDTO> result = new List <ReadArtifactDTO>();

            foreach (var item in artifacts)
            {
                ReadArtifactDTO dto = new ReadArtifactDTO();

                dto              = _mapper.Map <ReadArtifactDTO>(item);
                dto.RoomName     = item.Room.Name;
                dto.FloorName    = item.Room.Floor.Name;
                dto.BuildingName = item.Room.Floor.Building.Name;
                result.Add(dto);
            }
            return(result);
        }
Beispiel #3
0
        public async Task <ReadContentDTO> GetContentWithBeacon(GetContentWithBeaconDTO input)
        {
            //Get Beacon for Major Minor and UUID.
            var beacon = await _beaconRepository.GetAll()
                         .FirstOrDefaultAsync(x => x.UUID == input.UUID && x.Major == input.Major && x.Minor == input.Minor);

            //create analytics
            // await _analyticService.CreateAnalytic (new CreateAnalyticDTO(beacon.Id));

            //Get Relation for beacon ID
            var relation = await _relationRepository.GetAll()
                           .Include(x => x.Beacon)
                           .Where(x => x.Beacon.Id == beacon.Id && GetEnumString(x.Proximity) == input.Proximity).FirstOrDefaultAsync();

            ReadContentDTO da = new ReadContentDTO();

            if (relation != null)
            {
                return(_mapper.Map <ReadContentDTO>(relation.Content));
            }
            else
            {
                return(da);
            }
        }
Beispiel #4
0
        public async Task <User> Login(LoginUserDTO input)
        {
            try
            {
                // get user for Login

                var getUser = await _userRepository.GetAll()
                              .Where(x => x.Email == input.Email)
                              .FirstOrDefaultAsync();

                // take user s hash
                string correctHash = getUser.Hash;
                // confirm password and hash
                bool confirmPassword = Helpers.PasswordHelper.ValidatePassword(input.Password, correctHash);

                // Login
                if (confirmPassword.Equals(true) && getUser.IsActive.Equals(true))
                {
                    return(getUser);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #5
0
        // LocationID
        public async Task <List <ReadBeaconDTO> > GetAllBeacons(EntityDTO input)
        {
            var beacons = await _beaconRepository
                          .GetAll()
                          .Include(x => x.Artifact)
                          .Where(x => x.IsActive && x.Artifact.Room.Floor.Building.Location.Id == input.Id)  //FIXME not sure why there is x.artifact.id check ?
                          .ToListAsync();

            var result = _mapper.Map <List <ReadBeaconDTO> >(beacons);

            return(result);
        }
Beispiel #6
0
        // LocationID
        public async Task <List <ReadBeaconDTO> > GetAllBeacons(EntityDTO input)
        {
            var beacons = await _beaconRepository
                          .GetAll()
                          .Include(x => x.Location)
                          .Where(x => x.IsActive && x.Location.Id == input.Id)
                          .ToListAsync();

            var result = _mapper.Map <List <ReadBeaconDTO> >(beacons);

            return(result);
        }
Beispiel #7
0
        public async Task <List <ReadContentDTO> > GetAllCampaignContents(EntityDTO input)
        {
            var contents = await _repository
                           .GetAll()
                           .Include(x => x.Location)
                           .Where(x => x.IsActive && x.IsCampaign && x.Location.Id == input.Id)
                           .ToListAsync();

            var result = _mapper.Map <List <ReadContentDTO> >(contents);

            return(result);
        }
Beispiel #8
0
        public async Task UpdateRelation(UpdateRelationDTO input)
        {
            Relation result = await _relationRepository.GetById(input.Id);

            if (input.ArtifactId != Guid.Empty)
            {
                result.Artifact = await _artifactRepository.GetById(input.ArtifactId);

                result.Location = result.Artifact.Location;
            }
            if (input.BeaconId != Guid.Empty)
            {
                result.Beacon = await _beaconRepository.GetById(input.BeaconId);
            }
            if (input.ContentId != Guid.Empty)
            {
                result.Content = await _contentRepository.GetById(input.ContentId);
            }
            if (!String.IsNullOrEmpty(input.Proximity))
            {
                result.Proximity = (Proximity)Enum.Parse(typeof(Proximity), input.Proximity, true);
            }

            var artifact = await _artifactRepository.GetAll()
                           .Include(x => x.Location)
                           .Where(x => x.Id == input.Id)
                           .FirstOrDefaultAsync();

            result.Location = artifact.Location;

            await _relationRepository.Update(input.Id, result);
        }
Beispiel #9
0
        public async Task <List <ReadBeaconActivityDTO> > GetAllBeaconActivities(EntityDTO input)
        {
            var beaconActivities = await _beaconActivityRepository
                                   .GetAll()

                                   .Include(a => a.Beacon)
                                   .ThenInclude(x => x.Artifact)
                                   .ThenInclude(x => x.Room)
                                   .ThenInclude(x => x.Floor)
                                   .ThenInclude(x => x.Building)
                                   .ThenInclude(x => x.Location)
                                   .Where(z => z.IsActive == true).ToListAsync();


            var result = _mapper.Map <List <ReadBeaconActivityDTO> >(beaconActivities);

            /*foreach (var item in beaconActivities)
             * {
             *  ReadBeaconActivityDTO dto = new ReadBeaconActivityDTO();
             *
             *  dto = _mapper.Map<ReadBeaconActivityDTO>(item);
             *  dto.BuildingName = item.Building.Name;
             *
             *  result.Add(dto);
             * }*/
            return(result);
        }
Beispiel #10
0
 public BeaconActivityService(IBaseGenericRepository <BeaconActivity> repository, IBaseGenericRepository <Beacon> beaconRepository, IMapper mapper)
 {
     _beaconActivityRepository = repository;
     _beaconRepository         = beaconRepository;
     _mapper   = mapper;
     publicSet = _beaconActivityRepository.GetAll();
 }
Beispiel #11
0
        public async Task <List <ReadRoomDTO> > GetAllRooms(EntityDTO input)
        {
            var rooms = await _roomRepository.GetAll()
                        .Include(x => x.Floor)
                        .ThenInclude(x => x.Building)
                        .ThenInclude(x => x.Location)
                        .Where(x => x.IsActive == true && x.Floor.Building.Location.Id == input.Id)
                        .ToListAsync();

            List <ReadRoomDTO> result = _mapper.Map <List <ReadRoomDTO> >(rooms);

            for (int i = 0; i < rooms.Count; i++)
            {
                result[i].FloorName = rooms[i].Floor.Name;
            }
            return(result);
        }
Beispiel #12
0
        public async Task <List <ReadProjectDTO> > GetAllProject()
        {
            var projects = await _repository.GetAll()
                           .Where(z => z.IsActive == true).ToListAsync();

            var result = _mapper.Map <List <ReadProjectDTO> >(projects);

            return(result);
        }
Beispiel #13
0
        //ProjectID
        //GetAll locations on System
        public async Task <List <ReadLocationDTO> > GetAllLocation(EntityDTO input)
        {
            var locations = await _repository
                            .GetAll()
                            .Include(a => a.Project)
                            .Where(x => x.IsActive && x.Project.Id == input.Id)
                            .ToListAsync();

            List <ReadLocationDTO> result = new List <ReadLocationDTO>();

            foreach (var item in locations)
            {
                ReadLocationDTO dto = new ReadLocationDTO();

                dto             = _mapper.Map <ReadLocationDTO>(item);
                dto.ProjectName = item.Project.Name;

                result.Add(dto);
            }
            return(result);
        }
Beispiel #14
0
        //Location ID
        public async Task <List <ReadBuildingDTO> > GetAllBuildings(EntityDTO input)
        {
            var buildings = await _buildingRepository
                            .GetAll()
                            .Include(x => x.Location)
                            .Where(x => x.IsActive && x.Location.Id == input.Id)
                            .ToListAsync();

            List <ReadBuildingDTO> result = new List <ReadBuildingDTO>();

            foreach (var item in buildings)
            {
                ReadBuildingDTO dto = new ReadBuildingDTO();

                dto = _mapper.Map <ReadBuildingDTO>(item);
                dto.LocationName = item.Location.Name;

                result.Add(dto);
            }
            return(result);
        }
Beispiel #15
0
        //LocationID
        public async Task <List <ReadFloorDTO> > GetAllFloor(EntityDTO input)
        {
            var floors = await _repository
                         .GetAll()
                         .Include(x => x.Building)
                         .ThenInclude(a => a.Location)
                         .Where(x => x.Building.Location.Id == input.Id)
                         .ToListAsync();

            List <ReadFloorDTO> result = new List <ReadFloorDTO>();

            foreach (var item in floors)
            {
                ReadFloorDTO dto = new ReadFloorDTO();

                dto = _mapper.Map <ReadFloorDTO>(item);
                dto.BuildingName = item.Building.Name;

                result.Add(dto);
            }
            return(result);
        }
Beispiel #16
0
        public async Task CreateAnalytic(CreateAnalyticDTO input)
        {
            //Get Beacon for Major Minor and UUID.
            var beacon = await _beaconRepository.GetAll()
                         .FirstOrDefaultAsync(x => x.Id == input.BeaconId);

            if (beacon != null)
            {
                Statistics result = new Statistics()
                {
                    BeaconId = beacon.Id
                };
                await _statisticRepository.Create(result);
            }
            else
            {
                return;
            }
        }
Beispiel #17
0
        public async Task <List <ReadAnalyticDTO> > GetAllBeaconsWithHours(EntityDTO input)
        {
            var data = await _statisticRepository
                       .GetAll()
                       .Include(x => x.Beacon)
                       .ThenInclude(x => x.Location)
                       .Where(x => x.IsActive && x.CreatedTime.AddDays(30) > DateTime.Now && x.Beacon.Location.Id == input.Id)
                       .ToListAsync();

            List <ReadAnalyticDTO> result = new List <ReadAnalyticDTO>();

            foreach (var item in data)
            {
                ReadAnalyticDTO dto = new ReadAnalyticDTO();
                dto.BeaconName  = item.Beacon.Name;
                dto.CreatedTime = item.CreatedTime;
                dto.IsActive    = item.IsActive;
                result.Add(dto);
            }
            return(result);
        }
Beispiel #18
0
 /// <inheritdoc />
 public Task <List <TEntity> > GetAll()
 {
     return(Repository.GetAll());
 }