Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public async Task<IHttpActionResult> CreateOpportunity(PayPalDetailsDto payPalDetailsDto)
        {
            StatusMessage status = new StatusMessage();
            string companyId = User.Identity.GetUserId();
            string crmContactId = this.youfferContactService.GetMappingEntryByContactId(payPalDetailsDto.UserId).ContactCRMId;
            string crmLeadId = this.youfferContactService.GetMappingEntryByContactId(payPalDetailsDto.UserId).LeadId;
            ApplicationUserDto compantDet = this.youfferContactService.GetOrgCRMId(companyId);
            string crmOrgId = compantDet.CRMId;
            LeadModel leadModel = this.crmManagerService.GetLead(crmLeadId);
            OrganisationModel org = this.crmManagerService.GetOrganisation(companyId);

            double price = Convert.ToDouble(payPalDetailsDto.Amount);
            status.IsSuccess = this.crmManagerService.AddOpportunity(leadModel, crmOrgId, crmContactId, price, payPalDetailsDto, null);

            if (status.IsSuccess)
            {
                org.AnnualRevenue += price;
                this.crmManagerService.UpdateOrganisation(companyId, org);
            }

            if (!string.IsNullOrEmpty(leadModel.GCMId))
            {
                this.pushMessageService.SendPurchasedNotificationToAndroid(leadModel.GCMId, companyId, compantDet.Name, payPalDetailsDto.Interest, "Purchased", Notification.buyuser.ToString());
            }

            if (!string.IsNullOrEmpty(leadModel.UDId))
            {
                this.pushMessageService.SendPurchasedNotificationToiOS(leadModel.UDId, companyId, compantDet.Name, "Purchased", Notification.buyuser.ToString());
            }

            CRMNotifications notification = new CRMNotifications()
            {
                OrganisationsId = crmOrgId,
                ContactId = crmContactId,
                NotificationType = ConfigConstants.OrganisationPurchasedContact
            };

            this.crmManagerService.CreateNotification(notification);

            return this.Ok(status);
        }
Esempio n. 3
0
        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);
        }