public PagedResult <SuplementDTO> GetSuplements(Token token, GetSupplementsParam param, PartialRetrievingInfo retrievingInfo) { var securityInfo = SecurityManager.EnsureAuthentication(token); var service = new SupplementService(Session, securityInfo, Configuration); return(service.GetSuplements(param, retrievingInfo)); }
protected override void RetrieveObjects(BodyArchitectAccessServiceClient client1, PartialRetrievingInfo pageInfo, EventHandler <GetSuplementsCompletedEventArgs> operationCompleted) { var param = new GetSupplementsParam(); client1.GetSuplementsAsync(ApplicationState.Current.SessionData.Token, param, pageInfo); client1.GetSuplementsCompleted -= operationCompleted; client1.GetSuplementsCompleted += operationCompleted; }
public void OnlyLegal() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { var param = new GetSupplementsParam(); param.LegalCriteria = CanBeIllegalCriteria.OnlyLegal; var list = service.GetSuplements(data.Token, param, new PartialRetrievingInfo()); assert(list, 0, 1, 2); }); }
public PagedResult <SuplementDTO> GetSuplements(GetSupplementsParam param, PartialRetrievingInfo retrievingInfo) { Log.WriteWarning("GetSuplements:Username={0}", SecurityInfo.SessionData.Profile.UserName); var session = Session; var profileResult = session.QueryOver <Suplement>(); if (param.ProductCriteria == SupplementProductCriteria.OnlyProducts) { profileResult = profileResult.Where(x => x.IsProduct); } else if (param.ProductCriteria == SupplementProductCriteria.OnlyGeneral) { profileResult = profileResult.Where(x => !x.IsProduct); } if (param.LegalCriteria == CanBeIllegalCriteria.OnlyIllegal) { profileResult = profileResult.Where(x => x.CanBeIllegal); } else if (param.LegalCriteria == CanBeIllegalCriteria.OnlyLegal) { profileResult = profileResult.Where(x => !x.CanBeIllegal); } profileResult = profileResult.ApplySorting(param.SortOrder, param.SortAscending); var res1 = (from rv in session.Query <RatingUserValue>() from tp in session.Query <Suplement>() where tp.GlobalId == rv.RatedObjectId && rv.ProfileId == SecurityInfo.SessionData.Profile.GlobalId select rv).ToDictionary(t => t.RatedObjectId); return(profileResult.ToPagedResults <SuplementDTO, Suplement>(retrievingInfo, null, delegate(IEnumerable <Suplement> list) { var output = new List <SuplementDTO>(); foreach (var planDto in list) { var tmp = planDto.Map <SuplementDTO>(); if (res1.ContainsKey(planDto.GlobalId)) { tmp.UserRating = res1[planDto.GlobalId].Rating; tmp.UserShortComment = res1[planDto.GlobalId].ShortComment; } output.Add(tmp); } return output.ToArray(); })); }
public PagedResult <SuplementDTO> GetSuplements(Token token, GetSupplementsParam param, PartialRetrievingInfo retrievingInfo) { return(exceptionHandling(token, () => InternalService.GetSuplements(token, param, retrievingInfo))); }