Пример #1
0
        public async Task Register(CreateUserDTO input)
        {
            // Password Hashing
            string hashedPassword = Helpers.PasswordHelper.HashPassword(input.Password);

            input.Password = hashedPassword;
            // IsActive of new user is default false
            input.IsActive = false;
            // Create a new GuidKey (Confirmation Key)
            string GuidKey = Guid.NewGuid().ToString();

            // Define GuidKey to Token
            input.Token = GuidKey;
            try
            {
                // Send an email for account confirmation
                Helpers.EmailHelper.SendMail(input.Email, GuidKey);
                var user = _mapper.Map <User>(input);
                user.Hash     = input.Password;
                user.RoleName = ERole.Common.ToString();
                await _userRepository.Create(user);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #2
0
        public async Task CreateBeacon(CreateBeaconDTO input)
        {
            var beacon = _mapper.Map <Beacon>(input);

            beacon.Artifact = await _artifactRepository.GetById(input.ArtifactId);

            await _beaconRepository.Create(beacon);
        }
Пример #3
0
        public async Task CreateBuilding(CreateBuildingDTO input)
        {
            var building = _mapper.Map <Building>(input);

            building.Location = await _locationRepository.GetById(input.LocationId);

            await _buildingRepository.Create(building);
        }
Пример #4
0
        public async Task CreateBeaconActivity(CreateBeaconActivityDTO input)
        {
            var beaconActivity = _mapper.Map <BeaconActivity>(input);

            beaconActivity.Beacon = await _beaconRepository.GetById(input.BeaconId);

            await _beaconActivityRepository.Create(beaconActivity);
        }
Пример #5
0
        public async Task CreateFloor(CreateFloorDTO input)
        {
            var floor = _mapper.Map <Floor>(input);

            floor.Building = await _buildingRepository.GetById(input.BuildingId); //firstly you must get building with building ID

            await _repository.Create(floor);                                      // and then you can push on create method
        }
Пример #6
0
        public async Task CreateBeacon(CreateBeaconDTO input)
        {
            var beacon = _mapper.Map <Beacon>(input);

            beacon.Location = await _locationRepository.GetById(input.LocationId);

            await _beaconRepository.Create(beacon);
        }
Пример #7
0
        public async Task CrateContent(CreateContentDTO input)
        {
            var content = _mapper.Map <Content>(input);

            content.Location = await _locationRepository.GetById(input.LocationId);

            await _repository.Create(content);
        }
Пример #8
0
        public async Task CreateArtifact(CreateArtifactDTO input)
        {
            var artifact = _mapper.Map <Artifact>(input);

            artifact.RoomId = input.RoomId;

            artifact.LocationId = input.LocationId;
            await _artifactRepository.Create(artifact);
        }
Пример #9
0
        public async Task CreateLocation(CreateLocationDTO input)
        {
            var location = _mapper.Map <Location>(input);

            location.Project = await _projectRepository.GetById(input.ProjectId);

            location.User = await _userRepository.GetById(input.UserId);

            await _repository.Create(location);
        }
Пример #10
0
        /// <inheritdoc />
        public Task <TEntity> Create(TEntity newEntity, bool modelState)
        {
            if (!modelState)
            {
                throw new MccBadRequestException("New entity does not have a valid model state");
            }
            CheckEntityIsValid(newEntity);


            return(Repository.Create(newEntity));
        }
Пример #11
0
        public async Task CreateRelation(CreateRelationDTO input)
        {
            Relation relation = new Relation()
            {
                ArtifactId = input.ArtifactId,
                ContentId  = input.ContentId,
                BeaconId   = input.BeaconId,
                Proximity  = (Proximity)Enum.Parse(typeof(Proximity), input.Proximity, true),
            };

            relation.LocationId = input.LocationId;
            await _relationRepository.Create(relation);
        }
Пример #12
0
        public async Task CreateRoom(CreateRoomDTO input)
        {
            var room = _mapper.Map <Room>(input);

            if (input.FloorId != Guid.Empty)
            {
                room.Floor = await _floorRepository.GetById(input.FloorId);
            }

            if (input.BeaconId != Guid.Empty)
            {
                room.Beacon = await _beaconRepository.GetById(input.BeaconId);
            }
            await _roomRepository.Create(room);
        }
Пример #13
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;
            }
        }
Пример #14
0
 public async Task CreateProject(CreateProjectDTO input)
 {
     var project = _mapper.Map <Project>(input);
     await _repository.Create(project);
 }