コード例 #1
0
ファイル: SecurityUtil.cs プロジェクト: showmap/smartwalk
        public static AccessType GetAccess(
            this IAccessRecord record,
            IAuthorizer authorizer,
            SmartWalkUserRecord user)
        {
            if (record == null)
            {
                return(AccessType.AllowView);
            }

            var allowEdit =
                user != null &&
                (authorizer.Authorize(Permissions.EditAllContent) ||
                 (record.SmartWalkUserRecord != null &&
                  record.SmartWalkUserRecord.Id == user.Id &&
                  authorizer.Authorize(Permissions.EditOwnContent)));

            var result =
                allowEdit
                    ? AccessType.AllowEdit
                    : (authorizer.Authorize(Permissions.ViewAllContent)
                           ? AccessType.AllowView
                           : AccessType.Deny);

            return(result);
        }
コード例 #2
0
ファイル: ImportService.cs プロジェクト: showmap/smartwalk
        private EntityRecord CreateOrUpdateEntity(
            IEntity xmlEntity,
            EntityType type,
            SmartWalkUserRecord user)
        {
            var result = _entityRepository.Get(ent => ent.Name == xmlEntity.Name);

            if (result == null)
            {
                result = new EntityRecord
                {
                    Name = xmlEntity.Name.TrimIt(),
                    Type = (byte)type,
                    SmartWalkUserRecord = user,
                    DateCreated         = DateTime.UtcNow,
                    DateModified        = DateTime.UtcNow
                };

                _entityRepository.Create(result);
                _log.Add(string.Format("{0} entity created", result.Name));
            }

            result.Description = xmlEntity.Description.TrimIt();
            result.Picture     = xmlEntity.Logo;

            _entityRepository.Update(result);
            _entityRepository.Flush();
            _log.Add(string.Format("{0} entity updated", result.Name));

            CreateContacts(result, xmlEntity.Contacts);
            CreateOrUpdateAddresses(result, xmlEntity.Addresses);

            return(result);
        }
コード例 #3
0
        private List <ValidationError> ValidateVerification(SmartWalkUserRecord userRecord)
        {
            var result = new List <ValidationError>();

            if (!userRecord.EventMetadataRecords.Any())
            {
                result.Add(new ValidationError(
                               T("Events").ToString(),
                               T("You have to create at least one event before starting verification.").ToString()));
            }

            return(result);
        }
コード例 #4
0
ファイル: ImportService.cs プロジェクト: showmap/smartwalk
        private EventMetadataRecord CreateEventMetadata(
            Event xmlOrgEvent,
            EntityRecord hostEntity,
            SmartWalkUserRecord user)
        {
            var result = _eventMetadataRepository
                         .Get(evMet =>
                              evMet.EntityRecord.Id == hostEntity.Id &&
                              evMet.StartTime == xmlOrgEvent.StartDateObject.Date);

            if (result == null)
            {
                result = new EventMetadataRecord
                {
                    EntityRecord        = hostEntity,
                    StartTime           = xmlOrgEvent.StartDateObject.Date,
                    CombineType         = (int)CombineType.None,
                    SmartWalkUserRecord = user,
                    DateCreated         = DateTime.UtcNow,
                    DateModified        = DateTime.UtcNow,
                    Status = (byte)EventStatus.Public
                };

                _eventMetadataRepository.Create(result);
                _log.Add(string.Format("{0} event metadata created", result.Title));
            }

            result.Title       = xmlOrgEvent.Title;
            result.Description = xmlOrgEvent.Description;
            result.Picture     = xmlOrgEvent.Logo;
            SetEventMetadataCoordinate(result, xmlOrgEvent.Venues);

            _eventMetadataRepository.Update(result);
            _eventMetadataRepository.Flush();
            _log.Add(string.Format(
                         "{0} event metadata coordinates updated to ({1}, {2})",
                         result.Title,
                         result.Latitude,
                         result.Longitude));

            return(result);
        }