Example #1
0
        public List <SearchBag> SearchTopic(string q)
        {
            var topics = new List <Model.ORM.Topic>();
            List <SearchBag> topicsFound = new List <SearchBag>();

            if (!string.IsNullOrEmpty(q))
            {
                int idOrg = NimbusOrganization.Id;
                using (var db = DatabaseFactory.OpenDbConnection())
                {
                    //restringe a busca para o conteudo da organizacao
                    IEnumerable <int> idChannelTopic = db.Where <Channel>(ch => ch.Visible == true && ch.OrganizationId == idOrg).Select(ch => ch.Id);

                    //verificar se é tag
                    if (q.StartsWith("#"))
                    {
                        q      = q.TrimStart('#');
                        topics = db.Query <Model.ORM.Topic>(@"
                            select distinct [Topic].*
                            from [Tag], [TagChannel], [Topic], [Channel]
                            where [Tag].TagName collate Latin1_general_CI_AI like @search collate Latin1_general_CI_AI
                                  and [Tag].[Id] = [TagChannel].TagId and [Topic].ChannelId = [TagChannel].ChannelId and [Topic].Visibility = 1
                                  and [Channel].[Id] = [TagChannel].ChannelId and [Channel].Visible = 1 and [Channel].OrganizationId = @organization",
                                                            new { search = "%" + q + "%", organization = idOrg });
                    }
                    else
                    {
                        topics = db.Query <Model.ORM.Topic>(
                            @"select distinct [Topic].*
from [Topic], [Channel]
where ([Topic].[Text] collate Latin1_general_CI_AI like @search collate Latin1_general_CI_AI
        or [Topic].[Title] collate Latin1_general_CI_AI like @search collate Latin1_general_CI_AI
	    or [Topic].[Description] collate Latin1_general_CI_AI like @search collate Latin1_general_CI_AI)
	    and [Topic].[Visibility] = 1 and [Channel].[Id] = [Topic].ChannelId and [Channel].[OrganizationId] = @organization"    ,
                            new { search = "%" + q + "%", organization = idOrg });
                    }
                }
                foreach (var item in topics)
                {
                    SearchBag bag = new SearchBag()
                    {
                        Description = item.Description,
                        IdItem      = item.Id,
                        Title       = item.Title,
                        TypeSearch  = "topic",
                        UrlImage    = item.ImgUrl,
                        ItemPageUrl = "topic"
                    };
                    topicsFound.Add(bag);
                }
            }
            return(topicsFound);
        }
Example #2
0
        public List <SearchBag> SearchChannel(string q)
        {
            List <SearchBag> channelsFound = new List <SearchBag>();
            var channels = new List <Model.ORM.Channel>();

            if (!string.IsNullOrEmpty(q))
            {
                int idOrg = NimbusOrganization.Id;

                using (var db = DatabaseFactory.OpenDbConnection())
                {
                    //verificar se é tag
                    if (q.StartsWith("#"))
                    {
                        q        = q.TrimStart('#');
                        channels = db.Query <Model.ORM.Channel>(@"
                                select distinct [Channel].*
                                from [Tag], [TagChannel], [Channel]
                                where [Tag].TagName collate Latin1_general_CI_AI like @search collate Latin1_general_CI_AI
                                        and [Tag].[Id] = [TagChannel].TagId and [Channel].[Id] = [TagChannel].ChannelId 
		                                and [Channel].Visible = 1 and [Channel].OrganizationId = @organization"        ,
                                                                new { search = "%" + q + "%", organization = idOrg });
                    }
                    else
                    {
                        channels = db.Query <Model.ORM.Channel>(@"
                                select distinct [Channel].*
                                from [Channel]
                                where [Channel].Name collate Latin1_general_CI_AI like @search collate Latin1_general_CI_AI
		                              and [Channel].Visible = 1 and [Channel].OrganizationId = @organization"        ,
                                                                new { search = "%" + q + "%", organization = idOrg });
                    }
                    foreach (var channel in channels)
                    {
                        SearchBag bag = new SearchBag();
                        bag.IdItem      = channel.Id;
                        bag.Title       = channel.Name;
                        bag.Description = channel.Description;
                        bag.UrlImage    = channel.ImgUrl.ToLower().Replace("/capachannel/", "/category/");
                        bag.TypeSearch  = "channel";
                        bag.ItemPageUrl = "channel";
                        channelsFound.Add(bag);
                    }
                }
            }
            return(channelsFound);
        }
Example #3
0
        public List <SearchBag> SearchUser(string q)
        {
            List <SearchBag> usersFound = new List <SearchBag>();

            if (!string.IsNullOrEmpty(q))
            {
                int idOrg = NimbusOrganization.Id;
                using (var db = DatabaseFactory.OpenDbConnection())
                {//restringir a busca pela organizaçao
                    var users = db.Query <Model.ORM.User>(
                        @"
                            SELECT [User].[Id], [User].[FirstName], [User].[LastName],
                                   [User].[Occupation], [User].[Interest], [User].[AvatarUrl]
                            FROM [User]
                            WHERE ( (([User].[FirstName] COLLATE Latin1_general_CI_AI LIKE @search COLLATE Latin1_general_CI_AI) OR 
			                         ([User].[LastName] COLLATE Latin1_general_CI_AI LIKE @search COLLATE Latin1_general_CI_AI) OR 
			                         ([User].[Occupation] COLLATE Latin1_general_CI_AI LIKE @search COLLATE Latin1_general_CI_AI) OR 
			                         ([User].[Interest] COLLATE Latin1_general_CI_AI LIKE @search COLLATE Latin1_general_CI_AI)) AND (NOT([User].[Password] = '') OR [User].[Password] IS NULL)
                                  ) ", new { search = "%" + q + "%", vazia = "" });

                    foreach (var item in users)
                    {
                        string description = !string.IsNullOrEmpty(item.Interest) ? item.Interest : item.Occupation;
                        description = !string.IsNullOrEmpty(description) ? description : item.Experience;
                        description = !string.IsNullOrEmpty(description) ? description : "Sem informações adicionais.";

                        SearchBag bag = new SearchBag()
                        {
                            Description = description,
                            IdItem      = item.Id,
                            Title       = item.FirstName + " " + item.LastName,
                            UrlImage    = item.AvatarUrl,
                            TypeSearch  = "user",
                            ItemPageUrl = "userprofile"
                        };
                        usersFound.Add(bag);
                    }
                }
            }
            return(usersFound);
        }
 public ActionResult MyActionMethod(SearchBag searchBag)
 {
     Effects selectedEffect = searchBag.EffectIndicator;
 }