/// <summary> /// Get all TransferValueProfiles for the provided entity /// The returned entities are just the base /// </summary> /// <param name="parentUid"></param> /// <returns></returnsThisEntity public static List <TransferValueProfile> GetAll(Guid parentUid) { List <TransferValueProfile> list = new List <TransferValueProfile>(); TransferValueProfile entity = new TransferValueProfile(); Entity parent = EntityManager.GetEntity(parentUid); LoggingHelper.DoTrace(7, string.Format("EntityTransferValueProfiles_GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId)); try { using (var context = new EntityContext()) { List <DBEntity> results = context.Entity_TransferValueProfile .Where(s => s.EntityId == parent.Id) .OrderBy(s => s.TransferValueProfile.Name) .ToList(); if (results != null && results.Count > 0) { foreach (DBEntity item in results) { entity = new TransferValueProfile(); //need to distinguish between on a detail page for conditions and TransferValueProfile detail //would usually only want basics here?? //17-05-26 mp- change to MapFromDB_Basic if (item.TransferValueProfile != null && item.TransferValueProfile.EntityStateId > 1) { TransferValueProfileManager.MapFromDB(item.TransferValueProfile, entity, false); list.Add(entity); } } } return(list); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + string.Format(".EntityTransferValueProfiles_GetAll. Guid: {0}, parentType: {1} ({2}), ", parentUid, parent.EntityType, parent.EntityBaseId)); } return(list); }
public static ThisEntity Get(int parentId, int TransferValueProfileId) { ThisEntity entity = new ThisEntity(); if (parentId < 1 || TransferValueProfileId < 1) { return(entity); } try { using (var context = new EntityContext()) { EM.Entity_TransferValueProfile from = context.Entity_TransferValueProfile .SingleOrDefault(s => s.TransferValueProfileId == TransferValueProfileId && s.EntityId == parentId); if (from != null && from.Id > 0) { entity.Id = from.Id; entity.TransferValueProfileId = from.TransferValueProfileId; entity.EntityId = from.EntityId; entity.TransferValueProfile = new TransferValueProfile(); TransferValueProfileManager.MapFromDB(from.TransferValueProfile, entity.TransferValueProfile); if (IsValidDate(from.Created)) { entity.Created = ( DateTime )from.Created; } } } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".Get"); } return(entity); } //