public async Task<IHttpActionResult> GetOpportunities(int lastpageId = 0, int fetchCount = 0, string sortBy = "", string direction = "asc")
        {
            List<PurchasedClientsDto> lstPurchasedClientsDto = new List<PurchasedClientsDto>();
            if (fetchCount == 0)
            {
                fetchCount = AppSettings.Get<int>(ConfigConstants.DashboardLeadsDefaultCount);
            }

            string companyId = User.Identity.GetUserId();
            List<VTigerPotential> lst = this.crmManagerService.GetOpportunities(companyId, lastpageId, fetchCount, sortBy, direction);

            foreach (var item in lst)
            {
                string contactId = this.userService.GetContactByCrmId(item.contact_id).Id;
                ContactModel contactModel = this.crmManagerService.GetContact(contactId);
                string crmOrgId = this.youfferContactService.GetOrgCRMId(companyId).CRMId;
                var reviewList = this.crmManagerService.ReadUserReviews(item.contact_id, crmOrgId, item.cf_853);
                CountryModel countryDet = this.commonService.GetUserCountryDetailsFromName(contactModel.MailingCountry);

                UserReviewsDto review = new UserReviewsDto();
                if (reviewList.Any())
                {
                    CRMUserReview crmReview = reviewList.First();
                    review = this.mapperFactory.GetMapper<CRMUserReview, UserReviewsDto>().Map(crmReview);
                }

                decimal rank = Convert.ToDecimal(this.crmManagerService.GetUserRank(item.contact_id));
                lstPurchasedClientsDto.Add(new PurchasedClientsDto { ClientId = contactId, Name = item.potentialname, ImageURL = contactModel.ImageURL, PhoneNumber = contactModel.Phone, BirthDay = contactModel.Birthday, Gender = contactModel.Gender, Rank = rank, Rating = review.Rating, Review = review.Feedback, Latitude = contactModel.Latitude, Longitude = contactModel.Longitude, Interest = item.cf_853, IsAvailable = contactModel.IsAvailable, CanCall = item.cf_843, IsOnline = contactModel.IsOnline, MarkPurchased = item.cf_857, CountryDet = countryDet });
            }

            return this.Ok(lstPurchasedClientsDto);
        }
        public async Task<IHttpActionResult> SaveUserReview(UserReviewsDto userReview)
        {
            string companyId = User.Identity.GetUserId();
            userReview.CompanyId = userReview.CreatedBy = userReview.ModifiedBy = companyId;

            List<ApplicationUserDto> appUsers = this.userService.GetUsers(userReview.UserId, companyId);
            string contactId = appUsers.Where(x => x.Id == userReview.UserId).Select(x => x.CRMId).First().ToString();
            string organisationId = appUsers.Where(x => x.Id == companyId).Select(x => x.CRMId).First().ToString();

            CRMUserReview review = new CRMUserReview()
            {
                FeedbackText = userReview.Feedback,
                Rating = userReview.Rating,
                InterestName = userReview.InterestName,
                OrganisationsId = organisationId,
                ContactId = contactId
            };

            var reviewList = this.crmManagerService.ReadUserReviews(contactId, organisationId, userReview.InterestName);
            foreach (var item in reviewList)
            {
                item.IsDeleted = true;
                this.crmManagerService.UpdateUserReview(item);
            }

            review = this.crmManagerService.AddUserReview(review);
            userReview.Id = review.Id;

            ContactModel contact = this.crmManagerService.GetContact(userReview.UserId);
            OrganisationModel org = this.crmManagerService.GetOrganisation(companyId);
            if (!string.IsNullOrEmpty(contact.GCMId))
            {
                this.pushMessageService.SendRatingNotificationToAndroid(contact.GCMId, companyId, org.AccountName, "Review User", userReview.Rating, Notification.rating.ToString());
            }

            if (!string.IsNullOrEmpty(contact.UDId))
            {
                this.pushMessageService.SendRatingNotificationToiOS(contact.UDId, companyId, org.AccountName, "Review User", userReview.Rating, Notification.rating.ToString());
            }

            return this.Ok(userReview);
        }