Пример #1
0
        public IHttpActionResult Get(int memberId)
        {
            using (bkContext context = new bkContext())
            {
                Matrimonial mat    = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId);
                Member      member = context.Members.FirstOrDefault(x => x.MemberID == memberId);
                if (mat == null)
                {
                    return(BadRequest("Matrimony profile cannot be loaded"));
                }

                MatrimonyViewModel model = new MatrimonyViewModel();

                model.Alcohol          = mat.Alcohol;
                model.BirthTime        = mat.BirthTime;
                model.BodyTypeId       = mat.BodyTypeID;
                model.ComplexionTypeId = mat.ComplexionTypeID;
                model.Disability       = mat.Disability;
                model.Height           = mat.Height;
                model.Language         = mat.Language;
                model.Mangal           = mat.Mangal;
                model.MaritalStatusId  = mat.MaritalStatusID;
                model.MaternalNukhId   = mat.MaternalNukhID;
                model.MemberId         = mat.MemberID;
                model.MonthlyIncome    = mat.MonthlyIncome;
                model.OwnHome          = mat.OwnHome;
                model.ProfileText      = mat.ProfileText;
                model.Smoke            = mat.Smoke;
                model.Tobacco          = mat.Tobacco;
                model.Vegetarian       = mat.Vegetarian;
                model.Weight           = mat.Weight;
                model.Photo1Url        = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 1, mat.ModifiedOn);
                model.Photo2Url        = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 2, mat.ModifiedOn);
                model.Photo3Url        = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 3, mat.ModifiedOn);

                return(Ok(model));
            }
        }
Пример #2
0
        public IHttpActionResult DeletePhoto(int photoNumber, int memberId)
        {
            if (!CanEditMember(memberId))
            {
                return(BadRequest("You do not have permission to edit this member"));
            }

            if (photoNumber < 1 || photoNumber > 3)
            {
                return(BadRequest("Invalid photo number"));
            }

            string filePath = System.Web.Hosting.HostingEnvironment.MapPath(string.Format(@"~/Images/Matrimonials/{0}_{1}.jpg", memberId, photoNumber));

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            string response = string.Empty;

            using (bkContext context = new bkContext())
            {
                Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId);
                if (mat != null)
                {
                    mat.ModifiedBy = LoggedInMemberId;
                    mat.ModifiedOn = DateTime.Now;

                    context.SaveChanges();
                }

                response = MemberWrapper.MatrimonyPhoto(memberId, mat.Member.Gender, photoNumber, mat.ModifiedOn);
            }

            return(Ok(response));
        }
Пример #3
0
        public IHttpActionResult GetMatrimony(int memberId)
        {
            using (bkContext context = new bkContext())
            {
                Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId);
                if (mat == null)
                {
                    return(BadRequest("Matrimony profile cannot be loaded"));
                }

                Member member = context.Members.FirstOrDefault(x => x.MemberID == memberId);
                if (member == null)
                {
                    return(BadRequest("Matrimony profile cannot be loaded"));
                }

                MatrimonyViewOnlyModel model = new MatrimonyViewOnlyModel();

                model.MatrimonyModel.Alcohol          = mat.Alcohol;
                model.MatrimonyModel.BirthTime        = mat.BirthTime;
                model.MatrimonyModel.BodyTypeId       = mat.BodyTypeID;
                model.MatrimonyModel.ComplexionTypeId = mat.ComplexionTypeID;
                model.MatrimonyModel.Disability       = mat.Disability;
                model.MatrimonyModel.Height           = mat.Height;
                model.MatrimonyModel.Language         = mat.Language;
                model.MatrimonyModel.Mangal           = mat.Mangal;
                model.MatrimonyModel.MaritalStatusId  = mat.MaritalStatusID;
                model.MatrimonyModel.MaternalNukhId   = mat.MaternalNukhID;
                model.MatrimonyModel.MemberId         = mat.MemberID;
                model.MatrimonyModel.MonthlyIncome    = mat.MonthlyIncome;
                model.MatrimonyModel.OwnHome          = mat.OwnHome;
                model.MatrimonyModel.ProfileText      = mat.ProfileText;
                model.MatrimonyModel.Smoke            = mat.Smoke;
                model.MatrimonyModel.Tobacco          = mat.Tobacco;
                model.MatrimonyModel.Vegetarian       = mat.Vegetarian;
                model.MatrimonyModel.Weight           = mat.Weight;
                model.MatrimonyModel.Photo1Url        = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 1, mat.ModifiedOn);
                model.MatrimonyModel.Photo2Url        = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 2, mat.ModifiedOn);
                model.MatrimonyModel.Photo3Url        = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 3, mat.ModifiedOn);

                model.MemberModel.MemberID        = member.MemberID;
                model.MemberModel.FirstName       = member.FirstName;
                model.MemberModel.LastName        = member.LastName;
                model.MemberModel.NickName        = member.NickName;
                model.MemberModel.Email           = member.EmailAddress;
                model.MemberModel.PhoneNumber     = member.Phone;
                model.MemberModel.Gender          = member.Gender;
                model.MemberModel.DOB             = member.DOB;
                model.MemberModel.BirthPlace      = member.BirthPlace;
                model.MemberModel.Alive           = member.Alive;
                model.MemberModel.DOD             = member.DOD;
                model.MemberModel.DeathPlace      = member.DeathPlace;
                model.MemberModel.EducationLevel  = member.EducationLevel;
                model.MemberModel.EducationField  = member.EducationField;
                model.MemberModel.OccupationId    = member.OccupationID;
                model.MemberModel.CompanyName     = member.CompanyName;
                model.MemberModel.JobTitle        = member.JobTitle;
                model.MemberModel.InstagramHandle = member.InstagramHandle;
                model.MemberModel.FacebookHandle  = member.FacebookHandle;
                model.MemberModel.TwitterHandle   = member.TwitterHandle;
                model.MemberModel.MaritalStatusId = member.MaritalStatusID;
                model.MemberModel.PhotoUrl        = MemberWrapper.ProfilePhoto(member.MemberID, member.Gender, member.ModifiedOn);
                model.MemberModel.FamilyId        = member.FamilyMemberAssociations.Where(x => x.DefaultFamily).Select(x => x.FamilyId).FirstOrDefault();

                model.MemberModel.ModifiedOn = mat.ModifiedOn.HasValue ? mat.ModifiedOn : mat.CreatedOn;
                if (member.ModifiedOn > model.MemberModel.ModifiedOn)
                {
                    model.MemberModel.ModifiedOn = member.ModifiedOn;
                }

                GetMaternalFamily_Result mResult = context.GetMaternalFamily(member.MemberID).FirstOrDefault();
                if (mResult != null)
                {
                    model.MemberModel.MaternalFamilyId   = mResult.MaternalFamilyID;
                    model.MemberModel.MaternalFamilyName = string.Format("{0}, {1}", mResult.MaternalFamilyName, mResult.MaternalFamilyAddress);
                }

                return(Ok(model));
            }
        }
Пример #4
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));
        }