Exemple #1
0
        public IHttpActionResult Search(MemberSearchModel model)
        {
            string firstName      = string.IsNullOrWhiteSpace(model.FirstName) ? null : model.FirstName.Trim();
            string lastName       = string.IsNullOrWhiteSpace(model.LastName) ? null : model.LastName.Trim();
            int?   categoryId     = model.CategoryID.HasValue && model.CategoryID.Value > 0 ? model.CategoryID : null;
            int?   nukhId         = model.NukhID.HasValue && model.NukhID.Value > 0 ? model.NukhID : null;
            string city           = string.IsNullOrWhiteSpace(model.City) ? null : model.City.Trim();
            string district       = string.IsNullOrWhiteSpace(model.District) ? null : model.District.Trim();
            string state          = string.IsNullOrWhiteSpace(model.State) ? null : model.State.Trim();
            string emailAddress   = string.IsNullOrWhiteSpace(model.Email) ? null : model.Email.Trim();
            string phoneNumber    = string.IsNullOrWhiteSpace(model.PhoneNumber) ? null : model.PhoneNumber.Trim();
            string sortOrder      = string.IsNullOrWhiteSpace(model.SortOrder) ? null : model.SortOrder.Trim();
            int?   currentPage    = model.CurrentPage.HasValue && model.CurrentPage.Value > 0 ? model.CurrentPage : null;
            int?   pageSize       = model.PageSize.HasValue && model.PageSize.Value > 0 ? model.PageSize : null;
            int?   memberId       = model.MemberId > 0 ? model.MemberId : (int?)null;
            bool   includeOnlyHOF = model.IncludeOnlyHOF;

            MemberSearchResultModel mvm = new MemberSearchResultModel();

            using (bkContext context = new bkContext())
            {
                ObjectParameter oParameter = new ObjectParameter("TotalRecords", typeof(int));

                List <bk_MemberSearch_Result> results = context.bk_MemberSearch(firstName, lastName, categoryId, nukhId, city, district, state, emailAddress, phoneNumber, pageSize, currentPage, includeOnlyHOF, sortOrder, memberId, null, oParameter).ToList();

                mvm.TotalRecords = (int)oParameter.Value;

                foreach (var result in results)
                {
                    var item = new MemberSearchResultItemModel();

                    item.Name     = $"{result.FirstName} {result.LastName}";
                    item.Address1 = $"{result.Address1}, {result.Address2}".TrimEnd(' ').TrimEnd(',').TrimStart(',');
                    item.Address2 = $"{result.City}, {result.District}, {result.State}, {result.Country}".TrimEnd(' ').TrimEnd(',').TrimStart(',').Replace(", , ", ", ");
                    item.MemberId = result.MemberID;
                    item.FamilyId = result.FamilyID;
                    item.Gender   = result.Gender;
                    item.Alive    = result.Alive;
                    item.DOB      = result.DOB;
                    item.DOD      = result.DOD;
                    item.PhotoUrl = MemberWrapper.ProfilePhoto(result.MemberID, result.Gender, result.ModifiedOn);

                    mvm.Results.Add(item);
                }
            }

            return(Ok(mvm));
        }
Exemple #2
0
        public IHttpActionResult Search(MatrimonySearchModel model)
        {
            int?     categoryId      = model.CategoryID.HasValue && model.CategoryID.Value > 0 ? model.CategoryID : null;
            int?     nukhId          = model.NukhID.HasValue && model.NukhID.Value > 0 ? model.NukhID : null;
            string   city            = string.IsNullOrWhiteSpace(model.City) ? null : model.City.Trim();
            string   district        = string.IsNullOrWhiteSpace(model.District) ? null : model.District.Trim();
            string   state           = string.IsNullOrWhiteSpace(model.State) ? null : model.State.Trim();
            string   country         = string.IsNullOrWhiteSpace(model.Country) ? null : model.Country.Trim();
            bool?    gender          = model.Gender;
            int?     occupationId    = model.OccupationId.HasValue && model.OccupationId.Value > 0 ? model.OccupationId : null;
            int?     maritalStatusId = model.MaritalStatusId.HasValue && model.MaritalStatusId.Value > 0 ? model.MaritalStatusId : null;
            int?     minAge          = model.MinimumAge.HasValue && model.MinimumAge.Value > 0 ? model.MinimumAge : null;
            int?     maxAge          = model.MaximumAge.HasValue && model.MaximumAge.Value > 0 ? model.MaximumAge : null;
            int?     currentPage     = model.CurrentPage.HasValue && model.CurrentPage.Value > 0 ? model.CurrentPage : null;
            int?     pageSize        = model.PageSize.HasValue && model.PageSize.Value > 0 ? model.PageSize : null;
            string   sortOrder       = string.IsNullOrWhiteSpace(model.SortOrder) ? null : model.SortOrder.Trim();
            DateTime?minDOB          = null;
            DateTime?maxDOB          = null;

            if (minAge.HasValue)
            {
                maxDOB = DateTime.Today.AddYears(minAge.Value * -1);
            }

            if (maxAge.HasValue)
            {
                minDOB = DateTime.Today.AddYears(maxAge.Value * -1);
            }

            MemberSearchResultModel mvm = new MemberSearchResultModel();

            using (bkContext context = new bkContext())
            {
                ObjectParameter oParameter = new ObjectParameter("TotalRecords", typeof(int));

                List <bk_MatrimonySearch_Result> results = context.bk_MatrimonySearch(categoryId, nukhId, city, district, state, country, gender, occupationId, maritalStatusId, minDOB, maxDOB, pageSize, currentPage, sortOrder, oParameter).ToList();

                mvm.TotalRecords = (int)oParameter.Value;

                foreach (var result in results)
                {
                    var item = new MemberSearchResultItemModel();

                    item.Name          = $"{result.FirstName} {result.LastName}";
                    item.Address1      = $"{result.Address1}, {result.Address2}".TrimEnd(' ').TrimEnd(',').TrimStart(',');
                    item.Address2      = $"{result.City}, {result.District}, {result.State}, {result.Country}".TrimEnd(' ').TrimEnd(',').TrimStart(',').Replace(", , ", ", ");
                    item.MemberId      = result.MemberID;
                    item.FamilyId      = result.FamilyID;
                    item.Gender        = result.Gender;
                    item.DOB           = result.DOB;
                    item.OccupationId  = result.OccupationID > 0 ? result.OccupationID : (int?)null;
                    item.MonthlyIncome = result.MonthlyIncome > 0 ? result.MonthlyIncome : (int?)null;

                    if (!string.IsNullOrWhiteSpace(result.EducationField) && !string.IsNullOrWhiteSpace(result.EducationLevel))
                    {
                        item.Education = $"{result.EducationLevel} - {result.EducationField}";
                    }
                    else if (!string.IsNullOrWhiteSpace(result.EducationLevel))
                    {
                        item.Education = $"{result.EducationLevel}";
                    }
                    else if (!string.IsNullOrWhiteSpace(result.EducationField))
                    {
                        item.Education = $"{result.EducationField}";
                    }

                    item.PhotoUrl  = MemberWrapper.ProfilePhoto(result.MemberID, result.Gender, result.ModifiedOn);
                    item.Photo1Url = MemberWrapper.MatrimonyPhoto(result.MemberID, result.Gender, 1, result.ModifiedOn);
                    item.Photo2Url = MemberWrapper.MatrimonyPhoto(result.MemberID, result.Gender, 2, result.ModifiedOn);
                    item.Photo3Url = MemberWrapper.MatrimonyPhoto(result.MemberID, result.Gender, 3, result.ModifiedOn);

                    mvm.Results.Add(item);
                }
            }

            return(Ok(mvm));
        }