public static async Task<UserDetailsVM> GetUserDetails(string id, bool direct = false) { UserDetailServiceProxy udsvc = new UserDetailServiceProxy(); var cntx = Cntx; cntx.DirectDataAccess = direct; var details = await udsvc.LoadEntityByKeyAsync(cntx, ApplicationContext.App.ID, id); UserDetailsVM m = null; if (details != null) { if (!details.IsDescriptionLoaded) { details.Description = udsvc.LoadEntityDescription(cntx, ApplicationContext.App.ID, id); details.IsDescriptionLoaded = true; } m = new UserDetailsVM { Details = details }; m.IsPhotoAvailable = !string.IsNullOrEmpty(details.PhotoMime); } else { m = new UserDetailsVM(); m.IsPhotoAvailable = false; } UserDetailSet uds = new UserDetailSet(); m.Genders = uds.GenderValues; QueryExpresion qexpr = new QueryExpresion(); qexpr.OrderTks = new List<QToken>(new QToken[] { new QToken { TkName = "ID" }, new QToken { TkName = "asc" } }); CommunicationTypeServiceProxy ctsvc = new CommunicationTypeServiceProxy(); var lct = await ctsvc.QueryDatabaseAsync(Cntx, new CommunicationTypeSet(), qexpr); m.ChannelTypes = lct.ToArray(); CommunicationServiceProxy csvc = new CommunicationServiceProxy(); //qexpr = new QueryExpresion(); //qexpr.OrderTks = new List<QToken>(new QToken[] { // new QToken { TkName = "TypeID" }, // new QToken { TkName = "asc" } //}); //qexpr.FilterTks = new List<QToken>(new QToken[] { // new QToken { TkName = "UserID" }, // new QToken { TkName = "==" }, // new QToken { TkName = "\"" + id + "\"" }, // new QToken { TkName = "&&" }, // new QToken { TkName = "ApplicationID" }, // new QToken { TkName = "==" }, // new QToken { TkName = "\"" + ApplicationContext.App.ID + "\"" } //}); //var lc = await csvc.QueryDatabaseAsync(Cntx, new CommunicationSet(), qexpr); var fkeys = new CommunicationSetConstraints { ApplicationIDWrap = new ForeignKeyData<string> { KeyValue = ApplicationContext.App.ID }, TypeIDWrap = null, // no restriction on types UserIDWrap = new ForeignKeyData<string> { KeyValue = id } }; var lc = await csvc.ConstraintQueryAsync(Cntx, new CommunicationSet(), fkeys, null); foreach (var c in lc) { c.Comment = await csvc.LoadEntityCommentAsync(Cntx, c.ID); c.IsCommentLoaded = true; c.CommunicationTypeRef = await csvc.MaterializeCommunicationTypeRefAsync(Cntx, c); m.Channels.Add(new { id = c.ID, label = c.DistinctString, addr = c.AddressInfo, comment = c.Comment, typeId = c.CommunicationTypeRef.TypeName }); } return m; }
/// <summary> /// Is it the same as the input one /// </summary> /// <param name="constraints">The one to be compared with.</param> /// <returns></returns> public bool IsTheSameAs(CommunicationSetConstraints constraints) { return ApplicationIDWrap.KeyValue == constraints.ApplicationIDWrap.KeyValue && TypeIDWrap.KeyValue == constraints.TypeIDWrap.KeyValue && UserIDWrap.KeyValue == constraints.UserIDWrap.KeyValue; }
/// <summary> /// Is it the same as the input one /// </summary> /// <param name="constraints">The one to be compared with.</param> /// <returns></returns> public bool IsTheSameAs(CommunicationSetConstraints constraints) { return(ApplicationIDWrap.KeyValue == constraints.ApplicationIDWrap.KeyValue && TypeIDWrap.KeyValue == constraints.TypeIDWrap.KeyValue && UserIDWrap.KeyValue == constraints.UserIDWrap.KeyValue); }