public string GetBaseViewList(string baseviewname, string orderby, string limit, string offset, string filter)
        {
            string returnData = _baseViewController.GetBaseViewList(baseviewname, orderby, limit, offset, filter);

            return(AnonymiseBaseviewData(returnData));
        }
示例#2
0
        public string GetUserPersona()
        {
            var userId = User.Claims.FirstOrDefault(cl => cl.Type.Equals("IPUId")).Value;

            List <object> baseviewPostBody = new List <object>();

            GetByPostBody getByPostBody = new GetByPostBody();

            string selectstatement       = "SELECT *";
            string ordergroupbystatement = string.Empty;

            GetByPostBodyFilter filters = new GetByPostBodyFilter()
            {
                FilterClause = "useridentifier IN (@userid)"
            };

            GetByPostBodyFilterParam filterparams = new GetByPostBodyFilterParam()
            {
                ParamName  = "userid",
                ParamValue = userId
            };

            baseviewPostBody.Add(new { filters = new GetByPostBodyFilter[] { filters } });
            baseviewPostBody.Add(new { filterparams = new GetByPostBodyFilterParam[] { filterparams } });
            baseviewPostBody.Add(new { selectstatement = selectstatement });
            baseviewPostBody.Add(new { ordergroupbystatement = ordergroupbystatement });

            //string personaJson = _baseViewController.GetBaseViewListByPost("meta_persona", null, null, null, null, JsonConvert.SerializeObject(baseviewPostBody));

            string personaJson = _baseViewController.GetBaseViewList("meta_persona", null, null, null, null);

            List <MetaPersonaBaseview> personaData = JsonConvert.DeserializeObject <List <MetaPersonaBaseview> >(personaJson);

            var groupedData = from data in personaData
                              group data by new
            {
                personaId        = data.persona_id,
                personaDispName  = data.personadispname,
                personaName      = data.personaname,
                personaDispOrder = data.personadisporder,
            } into personas
                select new Persona
            {
                PersonaId       = personas.Key.personaId,
                PersonaName     = personas.Key.personaName,
                DisplayName     = personas.Key.personaDispName,
                DisplayOrder    = personas.Key.personaDispOrder,
                PersonaContexts = new List <PersonaContext>()
            };

            var personaList = groupedData.ToList();

            foreach (var data in personaData)
            {
                Persona persona = personaList.First(per => per.PersonaId.Equals(data.persona_id));
                //Added condition
                bool personaContextExists = persona.PersonaContexts.Any(item => item.PersonaId == data.persona_id && item.DisplayName == data.displayname && item.ContextName == data.contextname);
                if (!personaContextExists)
                {
                    persona.PersonaContexts.Add(new PersonaContext
                    {
                        PersonaContextId = data.personacontext_id,
                        PersonaId        = data.persona_id,
                        ContextName      = data.contextname,
                        DisplayName      = data.displayname,
                        DisplayOrder     = data.displayorder
                    });
                }
            }

            return(JsonConvert.SerializeObject(personaList));
        }