Пример #1
0
        //POST: Ebay/OrderApiInitiateGuestCheckoutSession/{data}
        public ActionResult OrderApiInitiateGuestCheckoutSession(EbayOrderApiInitiateGuestCheckoutSessionModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };

            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid User" }));
            }

            AddressResultModel addressData = addressTable.SelectRecord(new SelectAddressModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            });

            CheckoutSessionResponse response = OrderAPI.InitiateGuestCheckoutSession(data.orderId, customerResult, addressData);

            InsertCustomerOrderModel customerOrder = new InsertCustomerOrderModel()
            {
                CustomerUUID      = customerResult.CustomerUUID,
                CheckoutSessionID = response.checkoutSessionId,
                ExpirationDate    = response.expirationDate,
                ImageURL          = data.imageUrl,
                PurchasePrice     = response.pricingSummary.total.value,
                Title             = response.lineItems[0].title
            };

            NonQueryResultModel orderResult = customerOrderTable.InsertRecord(customerOrder);

            return(Json(response));
        }
Пример #2
0
        public ActionResult Login(LoginLoginModel id)
        {
            //Get the customer's UUID, preferably in the future, instead of passing email addresses in,
            //We'll pass the UUID, or an Access Token
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = id.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            //Check to see if the customer exists
            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Credentials" }));
            }

            //Verify and report accordingly
            bool verifyHash = Password.VerifyHash(id.password, customerResult.Hash);

            if (verifyHash)
            {
                return(Json(new { result = "Success" }));
            }
            else
            {
                return(Json(new { result = "Fail", reason = "Invalid Credentials" }));
            }
        }
Пример #3
0
        public ActionResult SetSettings(QuerySetSettingsModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            UpdateQueryModel queryData = new UpdateQueryModel()
            {
                CustomerUUID = customerResult.CustomerUUID,
                Category     = data.category,
                CategoryID   = data.categoryId,
                Frequency    = data.frequencyOptions.label,
                PriceLimit   = data.price
            };
            NonQueryResultModel updateResult = queryTable.UpdateRecord(queryData);

            if (updateResult.Success)
            {
                return(Json(new { result = "Success" }));
            }
            else
            {
                return(Json(new { result = "Fail" }));
            }
        }
Пример #4
0
        public ActionResult ChangePassword(PreferenceChangePasswordModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            bool verifyPassword = Password.VerifyHash(data.oldPassword, customerResult.Hash);

            if (!verifyPassword)
            {
                return(Json(new { result = "Fail", reason = "Invalid Password" }));
            }

            //Generate Password's Salt and Hash
            byte[] salt       = Password.ComputeSaltBytes();
            string hashString = Password.ComputeHash(data.newPassword, salt);
            string saltString = Convert.ToBase64String(salt);

            customerResult.Hash = hashString;
            customerResult.Salt = saltString;

            UpdateCustomerModel customerUpdate = new UpdateCustomerModel()
            {
                CustomerUUID = customerResult.CustomerUUID,
                Email        = customerResult.Email,
                FirstName    = customerResult.FirstName,
                LastName     = customerResult.LastName,
                Hash         = customerResult.Hash,
                Salt         = customerResult.Salt,
                Phone        = customerResult.Phone
            };

            NonQueryResultModel updateResult = customerTable.UpdateRecord(customerUpdate);

            if (updateResult.Success)
            {
                return(Json(new { result = "Success" }));
            }
            else
            {
                return(Json(new { result = "Fail", reason = "Password was not updated" }));
            }
        }
Пример #5
0
        public ActionResult GetAddress(PreferenceGetAddressModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            AddressResultModel customerAddress = addressTable.SelectRecord(new SelectAddressModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            });

            return(Json(new { result = customerAddress }));
        }
Пример #6
0
        public ActionResult BrowseApiFindViableItems(EbayBrowseAPIModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            QueryResultModel queryPref = queryTable.SelectRecord(new SelectQueryModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            });

            return(Json(BrowseAPI.ItemSummarySearch(queryPref.CategoryID, queryPref.PriceLimit)));
        }
Пример #7
0
        public ActionResult GetSettings(QueryGetSettingsModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            QueryResultModel queryData = queryTable.SelectRecord(new SelectQueryModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            });

            return(Json(new { result = queryData }));
        }
Пример #8
0
        public ActionResult GetRecentPurchases(HomeGetRecentPurchaseModel id)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = id.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            SelectCustomerOrderModel customerOrderData = new SelectCustomerOrderModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            };
            List <CustomerOrderResultModel> orderResults = customerOrderTable.SelectAllRecords(customerOrderData);

            return(Json(new { result = orderResults }));
        }
Пример #9
0
        public ActionResult UpdateAddress(PreferenceAddressModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            UpdateAddressModel customerAddress = new UpdateAddressModel()
            {
                CustomerUUID = customerResult.CustomerUUID,

                BillingAddress  = data.streetName,
                BillingAddress2 = data.streetName2,
                BillingCity     = data.city,
                BillingState    = data.state,
                BillingZip      = data.postalCode,

                ShippingAddress  = data.streetName,
                ShippingAddress2 = data.streetName2,
                ShippingCity     = data.city,
                ShippingState    = data.state,
                ShippingZip      = data.postalCode
            };
            NonQueryResultModel updateResult = addressTable.UpdateRecord(customerAddress);

            if (updateResult.Success)
            {
                return(Json(new { result = "Success" }));
            }
            else
            {
                return(Json(new { result = "Fail", reason = "Database Update Failed" }));
            }
        }