/// <summary> /// Extension method. Return the unique value (as an entity) corresponding to the "SLAVE" grant type. /// </summary> /// <param name="grantTypes">Extension method parameter.</param> /// <returns>A GrantType instance of the Slave value.</returns> public static GrantType Slave(this DbSet <GrantType> grantTypes) { GrantType gtSlave = grantTypes.SingleOrDefault(gt => gt.Type == "SLAVE"); if (gtSlave == null) { return(null); } return(gtSlave); }
/// <summary> /// Extension method. Return the unique value (as an entity) corresponding to the "ALL" grant type. /// </summary> /// <param name="grantTypes">Extension method parameter.</param> /// <returns>A GrantType instance of the Administrator value.</returns> public static GrantType All(this DbSet <GrantType> grantTypes) { GrantType gtAll = grantTypes.SingleOrDefault(gt => gt.Type == "ALL"); if (gtAll == null) { return(null); } return(gtAll); }
/// <summary> /// Extension method. Return the unique value (as an entity) corresponding to the "MASTER" grant type. /// </summary> /// <param name="grantTypes">Extension method parameter.</param> /// <returns>A GrantType instance of the Master value.</returns> public static GrantType Master(this DbSet <GrantType> grantTypes) { GrantType gtMaster = grantTypes.SingleOrDefault(gt => gt.Type == "MASTER"); if (gtMaster == null) { return(null); } return(gtMaster); }
public static GrantedAccess AddOrUpdateAccess(this DbSet <GrantedAccess> accesses, GrantedUser user, Device device, GrantType type) { var access = accesses.FirstOrDefault(ga => ga.GrantedUserId == user.GrantedUserId && ga.DeviceId == device.DeviceId); if (access == null) { access = new GrantedAccess { DeviceId = device.DeviceId, GrantedUserId = user.GrantedUserId, GrantTypeId = type.GrantTypeId }; return(accesses.Add(access)); } access.DeviceId = device.DeviceId; access.GrantedUserId = user.GrantedUserId; access.GrantTypeId = type.GrantTypeId; return(access); }