Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the pay pal details.
        /// </summary>
        /// <param name="payPalDetailsDto">The pay pal details dto.</param>
        /// <returns>PayPalDetailsDto object.</returns>
        public PayPalDetailsDto SavePayPalDetails(PayPalDetailsDto payPalDetailsDto)
        {
            PayPalDetails payPalDetails = new PayPalDetails();
            payPalDetails = this.mapperFactory.GetMapper<PayPalDetailsDto, PayPalDetails>().Map(payPalDetailsDto);

            try
            {
                this.payPalDetailsRepository.Insert(payPalDetails);
                this.payPalDetailsRepository.Commit();

                payPalDetailsDto.Id = payPalDetails.Id;
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException("SavePayPalDetails - " + ex.Message);
            }

            return payPalDetailsDto;
        }