public static Order GenerateNewOrder(ProcessingResults results, long userId, long bidId, string gifts, long supplierId, decimal totalPrice, Source source)
        {
            //  var messageId = BIdMessageController.AddNewMessage(bidId, supplierId, 0, BIdMessageController.ADMIN_STAGE);
            var messageId = BIdMessageController.AddNewMessage(bidId, supplierId);

            var order = new Order
            {
                AppUserId             = userId,
                BidId                 = bidId,
                CreateDate            = DateTime.UtcNow,
                Last4Digits           = results.Last4Digits,
                UserPaySupplierStatus = UserPaymentStatus.NotPayed,
                TotalPrice            = totalPrice,
                Transaction           = results.CardToken,
                ExpiryDate            = results.CardExpiration,
                AuthNumber            = results.AuthNumber,
                Gifts                 = gifts,
                SpecialInstructions   = results.SpecialInstructions ?? "",
                NumOfPayments         = results.NumOfPayments,
                Source                = (int)source,
            };

            order.Save();

            AppUserCard paymentToken = AppUserCard.FetchByAppUserId(userId);

            if (paymentToken == null)
            {
                paymentToken = new AppUserCard();
            }
            paymentToken.AppUserId  = userId;
            paymentToken.CardToken  = results.CardToken;
            paymentToken.ExpiryDate = results.CardExpiration;
            paymentToken.Last4Digit = results.Last4Digits;
            if (!String.IsNullOrEmpty(results.PersonalId))
            {
                paymentToken.IdNumber = results.PersonalId;
            }
            paymentToken.Save();

            AppSupplier supplier = AppSupplier.FetchByID(supplierId);

            if (supplier != null)
            {
                supplier.MaxWinningsNum = (supplier.MaxWinningsNum > 0 ? supplier.MaxWinningsNum - 1 : 0);
                if (supplier.MaxWinningsNum == 0)
                {
                    // SupplierNotification.SendNotificationMaxAutoModeMessage(supplier.SupplierId);
                }
                supplier.Save();
            }
            SMSController.sendNewBidSMS(AppUser.FetchByID(userId).Phone);
            return(order);
        }
Beispiel #2
0
 public static void sendNewBidSMS(string PhoneNumberList)
 {
     SMSController.sendSMS(PhoneNumberList, AppResources.newBidSMSMessage);
 }