Exemplo n.º 1
0
        public SearchFilterVm organizationListExportForCertainOrg(int id, SearchFilterVm input)
        {
            using (var db = new MainDb())
            {
                var query = db.organizations
                            .Include(i => i.contactInfo)
                            .Where(e => (e.organizationId == id));
                if (query.Count() > 0)
                {
                    List <int> members = new List <int>();
                    foreach (OrganizationVo org in query)
                    {
                        members = OrganizationManager.getCountofMembersInOrg(org);
                        org.totalAmountofMembers = members.Count;
                    }
                }

                input.result = query.ToList <object>();

                if (input.result.Count() != 0)
                {
                    var items = new List <object>();

                    items.Add(
                        new
                    {
                        h1 = "Organization Name",
                        h2 = "Fee Amount",
                        h3 = "Has Paid Fee",
                        h4 = "Contact Name",
                        h5 = "Contact Work Phone",
                        h6 = "Contact Email",
                        h7 = "Total Members in Organization"
                    });

                    var item2 = query.AsEnumerable().Select(i =>
                                                            new
                    {
                        Name          = i.name,
                        Fee_Amount    = (i.feeAmount == null ? 0 : i.feeAmount),
                        HasPaidFee    = (i.hasPaidFee == null ? "N/A" : (i.hasPaidFee == true ? "Yes" : "No")),
                        Contact_Name  = i.contactInfo.firstName + " " + i.contactInfo.lastName,
                        Work_Phone    = i.contactInfo.workPhone,
                        Email         = (i.contactInfo == null ? "" : i.contactInfo.email ?? ""),
                        Total_Members = i.totalAmountofMembers
                    }).ToList <object>();

                    foreach (var i in item2)
                    {
                        items.Add(i);
                    }

                    input.result = items;
                }

                return(input);
            }
        }
Exemplo n.º 2
0
        //
        public SearchFilterVm organizationListExport(SearchFilterVm input)
        {
            int keywordInt = 0;

            int.TryParse(input.keyword, out keywordInt);
            if (keywordInt < 0)
            {
                keywordInt = 0;
            }

            using (var db = new MainDb())
            {
                var query = db.organizations
                            .Include(i => i.contactInfo)
                            .OrderByDescending(b => b.created)
                            .Where(e => (input.isActive == null || e.isActive == input.isActive) &&
                                   (e.name.Contains(input.keyword) || string.IsNullOrEmpty(input.keyword) ||
                                    e.contactInfo.firstName.Contains(input.keyword) ||
                                    e.contactInfo.lastName.Contains(input.keyword) ||
                                    e.contactInfo.address.Contains(input.keyword) ||
                                    e.organizationId == keywordInt ||
                                    e.contactInfoId == keywordInt ||
                                    e.feeAmount == keywordInt ||
                                    e.contactInfo.address.Contains(input.keyword) ||
                                    e.contactInfo.city.Contains(input.keyword)
                                   ));
                if (query.Count() > 0)
                {
                    List <int> members = new List <int>();
                    foreach (OrganizationVo org in query)
                    {
                        members = OrganizationManager.getCountofMembersInOrg(org);
                        org.totalAmountofMembers = members.Count;
                    }
                }

                input.result = query.ToList <object>();

                if (input.result.Count() != 0)
                {
                    var items = new List <object>();

                    items.Add(
                        new
                    {
                        h1 = "Organization Name",
                        h2 = "Fee Amount",
                        h3 = "Has Paid Fee",
                        h4 = "Contact Name",
                        h5 = "Contact Work Phone",
                        h6 = "Contact Email",
                        h7 = "Total Members in Organization"
                    });

                    var item2 = query.AsEnumerable().Select(i =>
                                                            new
                    {
                        Name          = i.name,
                        Fee_Amount    = (i.feeAmount == null ? 0 : i.feeAmount),
                        HasPaidFee    = (i.hasPaidFee == null ? "N/A" : (i.hasPaidFee == true ? "Yes" : "No")),
                        Contact_Name  = i.contactInfo.firstName + " " + i.contactInfo.lastName,
                        Work_Phone    = i.contactInfo.workPhone,
                        Email         = (i.contactInfo == null ? "" : i.contactInfo.email ?? ""),
                        Total_Members = i.totalAmountofMembers
                    }).ToList <object>();

                    foreach (var i in item2)
                    {
                        items.Add(i);
                    }

                    input.result = items;
                }

                return(input);
            }
        }