/// <summary> /// Saves the feedback. /// </summary> /// <param name="feedbackDto">The feedback.</param> /// <returns>FeedbackDto object.</returns> public FeedbackDto SaveFeedback(FeedbackDto feedbackDto) { try { Feedback feedback = this.mapperFactory.GetMapper<FeedbackDto, Feedback>().Map(feedbackDto); this.userFeedbackRepository.Insert(feedback); this.userFeedbackRepository.Commit(); feedbackDto.Id = feedback.Id; } catch (Exception ex) { this.LoggerService.LogException("SaveFeedback - " + ex.Message); } return feedbackDto; }
public async Task<IHttpActionResult> ReportUser(FeedbackDto feedback) { string companyId = User.Identity.GetUserId(); List<ApplicationUserDto> appUsers = this.userService.GetUsers(feedback.ToId, companyId); string contactId = appUsers.Where(x => x.Id == feedback.ToId).Select(x => x.CRMId).First().ToString(); string organisationId = appUsers.Where(x => x.Id == companyId).Select(x => x.CRMId).First().ToString(); feedback.FromId = feedback.CreatedBy = companyId; feedback.FeedbackId = Convert.ToInt32(Feedback.ReportUser); feedback = this.youfferFeedbackService.SaveFeedback(feedback); StatusMessage status = new StatusMessage(); status.IsSuccess = this.crmManagerService.ReportUser(contactId, organisationId); ContactModel contact = this.crmManagerService.GetContact(feedback.ToId); OrganisationModel org = this.crmManagerService.GetOrganisation(companyId); if (!string.IsNullOrEmpty(contact.GCMId)) { this.pushMessageService.SendReportUserNotificationToAndroid(contact.GCMId, companyId, org.AccountName, "Report User", Notification.reportuser.ToString()); } if (!string.IsNullOrEmpty(contact.UDId)) { this.pushMessageService.SendReportUserNotificationToiOS(contact.UDId, companyId, org.AccountName, "Report User", Notification.reportuser.ToString()); } CRMNotifications notification = new CRMNotifications() { OrganisationsId = organisationId, ContactId = contactId, NotificationType = ConfigConstants.OrganisationComplainedContact }; this.crmManagerService.CreateNotification(notification); return this.Ok(feedback); }
public async Task<IHttpActionResult> ReportCompany(FeedbackDto feedback) { string userId = User.Identity.GetUserId(); string crmContactId = this.userService.GetContact(userId).CRMId; string crmOrgId = this.userService.GetContact(feedback.ToId).CRMId; feedback.FromId = feedback.CreatedBy = userId; feedback.FeedbackId = Convert.ToInt32(Feedback.ReportCompany); feedback = this.youfferFeedbackService.SaveFeedback(feedback); StatusMessage status = new StatusMessage(); status.IsSuccess = this.crmManagerService.ReportCompany(crmContactId, crmOrgId); OrganisationModel organisation = this.crmManagerService.GetOrganisation(feedback.ToId); ContactModel contact = this.crmManagerService.GetContact(userId); if (!string.IsNullOrEmpty(organisation.GCMId)) { this.pushMessageService.SendReportCompanyNotificationToAndroid(organisation.GCMId, userId, contact.FirstName, "Fake Company", Notification.reportcompany.ToString()); } if (!string.IsNullOrEmpty(organisation.UDId)) { this.pushMessageService.SendReportCompanyNotificationToiOS(organisation.UDId, userId, contact.FirstName, "Fake Company", Notification.reportcompany.ToString()); } CRMNotifications notification = new CRMNotifications() { OrganisationsId = crmOrgId, ContactId = crmContactId, NotificationType = ConfigConstants.ContactComplainedOrganisation }; this.crmManagerService.CreateNotification(notification); return this.Ok(status); }