public IBlueprint EntityToBlueprint(BlueprintEntity toConvert, ICollection <WallEntity> wallEnts, ICollection <OpeningEntity> openEnts, ICollection <ColumnEntity> colEnts) { UserAndEntityConverter userEntityConverter = new UserAndEntityConverter(); User convertedUser = userEntityConverter.ToUser(toConvert.Owner); ICollection <Signature> convertedSignatures = GetBlueprintSignatures(toConvert); MaterialContainer materials = BuildUpContainer(wallEnts, openEnts, colEnts); IBlueprint conversion = new Blueprint(toConvert.Length, toConvert.Width, toConvert.Name, convertedUser, materials, convertedSignatures, toConvert.Id); return(conversion); }
private ICollection <User> TryFilter(Expression <Func <UserEntity, bool> > aCriteria) { ICollection <User> elegibleUsers = new List <User>(); using (BlueBuilderDBContext context = new BlueBuilderDBContext()) { UserAndEntityConverter translator = new UserAndEntityConverter(); IQueryable <UserEntity> elegibleRecords = context.Users.Where(aCriteria); foreach (UserEntity record in elegibleRecords) { elegibleUsers.Add(translator.ToUser(record)); } } return(elegibleUsers); }
private User TryGetFirst(Expression <Func <UserEntity, bool> > aCondition) { User firstToComply; using (BlueBuilderDBContext context = new BlueBuilderDBContext()) { UserAndEntityConverter translator = new UserAndEntityConverter(); UserEntity firstRecord = context.Users.FirstOrDefault(aCondition); if (firstRecord == null) { throw new UserNotFoundException(); } else { firstToComply = translator.ToUser(firstRecord); } } return(firstToComply); }