public async Task<IHttpActionResult> GetOpportunities1(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(); string crmOrgId = this.userService.GetContact(companyId).CRMId; List<VtigerPotentialData> lst = this.crmManagerService.GetMyClients(crmOrgId, string.Empty, lastpageId, fetchCount, sortBy, direction); foreach (var item in lst) { PurchasedClientsDto model = this.mapperFactory.GetMapper<VtigerPotentialData, PurchasedClientsDto>().Map(item); string crmContactId = AppSettings.Get<string>(ConfigConstants.ContactId) + item.contactid; var reviewList = this.crmManagerService.ReadUserReviews(crmContactId, crmOrgId, item.cf_853); CRMUserReview review = new CRMUserReview(); if (reviewList.Any()) { review = reviewList.First(); } model.ClientId = this.userService.GetContactByCrmId(crmContactId).Id; model.Rating = review.Rating; model.Review = review.FeedbackText; model.CountryDet = this.commonService.GetUserCountryDetailsFromName(item.mailingcountry); lstPurchasedClientsDto.Add(model); } 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); }