private bool Grant(string packageName, XmlNode xmlData, UserDto user) { var dto = new User2AppDto() { UserId = user.Id, AppAlias = packageName.ToLowerInvariant() }; LogHelper.Info <GrantPermissionForApp>("Granting permission to " + packageName.ToLowerInvariant() + " for user Id " + user.Id); _database.Insert(dto); return(true); }
public UserDto BuildDto(IUser entity) { var dto = new UserDto { ContentStartId = entity.StartContentId, MediaStartId = entity.StartMediaId, Disabled = entity.IsApproved == false, Email = entity.Email, Login = entity.Username, NoConsole = entity.IsLockedOut, Password = entity.RawPasswordValue, UserLanguage = entity.Language, UserName = entity.Name, Type = short.Parse(entity.UserType.Id.ToString(CultureInfo.InvariantCulture)), User2AppDtos = new List <User2AppDto>(), SecurityStampToken = entity.SecurityStamp, FailedLoginAttempts = entity.FailedPasswordAttempts, LastLockoutDate = entity.LastLockoutDate == DateTime.MinValue ? (DateTime?)null : entity.LastLockoutDate, LastLoginDate = entity.LastLoginDate == DateTime.MinValue ? (DateTime?)null : entity.LastLoginDate, LastPasswordChangeDate = entity.LastPasswordChangeDate == DateTime.MinValue ? (DateTime?)null : entity.LastPasswordChangeDate, }; foreach (var app in entity.AllowedSections) { var appDto = new User2AppDto { AppAlias = app }; if (entity.HasIdentity) { appDto.UserId = (int)entity.Id; } dto.User2AppDtos.Add(appDto); } if (entity.HasIdentity) { dto.Id = entity.Id.SafeCast <int>(); } return(dto); }
internal UserDto Map(UserDto a, User2AppDto p) { // Terminating call. Since we can return null from this function // we need to be ready for PetaPoco to callback later with null // parameters if (a == null) { return(Current); } // Is this the same DictionaryItem as the current one we're processing if (Current != null && Current.Id == a.Id) { if (p.AppAlias.IsNullOrWhiteSpace() == false) { // Yes, just add this User2AppDto to the current item's collection Current.User2AppDtos.Add(p); } // Return null to indicate we're not done with this User yet return(null); } // This is a different User to the current one, or this is the // first time through and we don't have one yet // Save the current User var prev = Current; // Setup the new current User Current = a; Current.User2AppDtos = new List <User2AppDto>(); //this can be null since we are doing a left join if (p.AppAlias.IsNullOrWhiteSpace() == false) { Current.User2AppDtos.Add(p); } // Return the now populated previous User (or null if first time through) return(prev); }
public UserDto BuildDto(IUser entity) { var dto = new UserDto { ContentStartId = entity.StartContentId, MediaStartId = entity.StartMediaId, DefaultToLiveEditing = entity.DefaultToLiveEditing, Disabled = entity.IsApproved == false, Email = entity.Email, Login = entity.Username, NoConsole = entity.NoConsole, Password = entity.Password, UserLanguage = entity.Language, UserName = entity.Name, Type = short.Parse(entity.UserType.Id.ToString()), DefaultPermissions = entity.DefaultPermissions, User2AppDtos = new List <User2AppDto>() }; foreach (var app in entity.AllowedSections) { var appDto = new User2AppDto { AppAlias = app }; if (entity.Id != null) { appDto.UserId = (int)entity.Id; } dto.User2AppDtos.Add(appDto); } if (entity.HasIdentity) { dto.Id = entity.Id.SafeCast <int>(); } return(dto); }