/// <summary>
        /// Initializes a new instance of the <see cref="CustomerDeviceFormViewModel"/> class.
        /// </summary>
        /// <param name="actionName">Name of the action.</param>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="device">The device.</param>
        /// <exception cref="System.ArgumentNullException">
        /// actionName
        /// or
        /// device
        /// </exception>
        public CustomerDeviceFormViewModel(string actionName, long customerId, CustomerDevice device)
        {
            if (customerId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(customerId));
            }
            if (string.IsNullOrWhiteSpace(actionName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(actionName));
            }

            this.CustomerId = customerId;
            this.ActionName = actionName;
            this.Device     = device ?? throw new ArgumentNullException(nameof(device));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the new customer device.
        /// </summary>
        /// <param name="customerModel">The customer model.</param>
        /// <param name="deviceName">Name of the device.</param>
        /// <param name="deviceManufacturer">The device manufacturer.</param>
        /// <param name="deviceCommissionDate">The device commision date.</param>
        /// <returns>
        /// Returns the create customer device model.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">customerModel</exception>
        /// <exception cref="System.ArgumentException">
        /// Value cannot be null or whitespace. - deviceName
        /// or
        /// Value cannot be null or whitespace. - deviceManufacturer
        /// </exception>
        public async Task <CustomerDevice> CreateNewCustomerDeviceAsync(
            Customer customerModel,
            string deviceName,
            string deviceManufacturer,
            DateTime?deviceCommissionDate)
        {
            if (customerModel == null)
            {
                throw new ArgumentNullException(nameof(customerModel));
            }
            if (string.IsNullOrWhiteSpace(deviceName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(deviceName));
            }

            // Date database fix
            if (deviceCommissionDate.HasValue)
            {
                if (deviceCommissionDate.Value < SqlDateTime.MinValue)
                {
                    deviceCommissionDate = SqlDateTime.MinValue.Value;
                }
                else if (deviceCommissionDate.Value > SqlDateTime.MaxValue)
                {
                    deviceCommissionDate = SqlDateTime.MaxValue.Value;
                }
            }

            // Create device assigned to customer
            var customer       = this.customersRepository.Get(customerModel.Id);
            var customerDevice = new CustomerDevice
            {
                Name           = deviceName,
                Manufacturer   = deviceManufacturer,
                CommissionDate = deviceCommissionDate
            };

            customer.CustomerDevices.Add(customerDevice);

            // Save changes
            await this.customersRepository.Save();

            // Return create customer device model
            return(customerDevice);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the customer device to the repository.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>
        /// Returns the customer device instance that was added to the repository.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">model</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">Id - Customer device identifier must be zero.</exception>
        public async Task <CustomerDevice> AddAsync(CustomerDevice model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (model.Id != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(model.Id), "Customer device identifier must be zero.");
            }

            // Add to the repository and save
            this.context.CustomerDevices.Add(model);
            await this.context.SaveChangesAsync();

            this.logger.Information(
                "Added new customer device {CustomerDeviceName} ({CustomerDeviceId}).",
                model.Name, model.Id);

            return(model);
        }
Exemplo n.º 4
0
        public Customer CheckCustomerLogin(LoginViewModel loginViewModel)
        {
            var customer = _customerRepository.Get(x => (x.Username.Equals(loginViewModel.Username) ||
                                                         x.PhoneNumber.Equals(loginViewModel.Username)) &&
                                                   x.PasswordHash.Equals(_customerService.HashPassword(loginViewModel.Password, Convert.FromBase64String(x.SaltPasswordHash))) &&
                                                   x.IsActive == true && x.Deleted == false);

            if (customer == null)
            {
                return(null);
            }
            var customerDevice = _customerDeviceRepository.Get(x => x.DeviceId == loginViewModel.DeviceId);

            if (customerDevice == null)
            {
                if (!string.IsNullOrEmpty(loginViewModel.DeviceId))
                {
                    customerDevice = new CustomerDevice
                    {
                        CustomerId = customer.Id,
                        DeviceId   = loginViewModel.DeviceId,
                        IsLogout   = false
                    };
                    _customerDeviceRepository.Add(customerDevice);
                }
            }
            else
            {
                customerDevice.IsLogout   = false;
                customerDevice.CustomerId = customer.Id;
                _customerDeviceRepository.Update(customerDevice);
            }
            _unitOfWork.CommitChanges();

            return(customer);
        }
        public async void Example()
        {
#pragma warning disable 0168
            using (Client client = GetClient())
            {
                Card card = new Card();
                card.CardNumber     = "4567350000427977";
                card.CardholderName = "Wile E. Coyote";
                card.Cvv            = "123";
                card.ExpiryDate     = "1220";

                RedirectionData redirectionData = new RedirectionData();
                redirectionData.ReturnUrl = "https://hostname.myownwebsite.url";

                ThreeDSecure threeDSecure = new ThreeDSecure();
                threeDSecure.AuthenticationFlow  = "browser";
                threeDSecure.ChallengeCanvasSize = "600x400";
                threeDSecure.ChallengeIndicator  = "challenge-requested";
                threeDSecure.ExemptionRequest    = "none";
                threeDSecure.RedirectionData     = redirectionData;
                threeDSecure.SkipAuthentication  = false;

                CardPaymentMethodSpecificInput cardPaymentMethodSpecificInput = new CardPaymentMethodSpecificInput();
                cardPaymentMethodSpecificInput.Card        = card;
                cardPaymentMethodSpecificInput.IsRecurring = false;
                cardPaymentMethodSpecificInput.MerchantInitiatedReasonIndicator = "delayedCharges";
                cardPaymentMethodSpecificInput.PaymentProductId   = 1;
                cardPaymentMethodSpecificInput.ThreeDSecure       = threeDSecure;
                cardPaymentMethodSpecificInput.TransactionChannel = "ECOMMERCE";

                AmountOfMoney amountOfMoney = new AmountOfMoney();
                amountOfMoney.Amount       = 2980L;
                amountOfMoney.CurrencyCode = "EUR";

                Address billingAddress = new Address();
                billingAddress.AdditionalInfo = "b";
                billingAddress.City           = "Monument Valley";
                billingAddress.CountryCode    = "US";
                billingAddress.HouseNumber    = "13";
                billingAddress.State          = "Utah";
                billingAddress.Street         = "Desertroad";
                billingAddress.Zip            = "84536";

                CompanyInformation companyInformation = new CompanyInformation();
                companyInformation.Name      = "Acme Labs";
                companyInformation.VatNumber = "1234AB5678CD";

                ContactDetails contactDetails = new ContactDetails();
                contactDetails.EmailAddress = "*****@*****.**";
                contactDetails.FaxNumber    = "+1234567891";
                contactDetails.PhoneNumber  = "+1234567890";

                BrowserData browserData = new BrowserData();
                browserData.ColorDepth   = 24;
                browserData.JavaEnabled  = false;
                browserData.ScreenHeight = "1200";
                browserData.ScreenWidth  = "1920";

                CustomerDevice device = new CustomerDevice();
                device.AcceptHeader             = "texthtml,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
                device.BrowserData              = browserData;
                device.IpAddress                = "123.123.123.123";
                device.Locale                   = "en-US";
                device.TimezoneOffsetUtcMinutes = "420";
                device.UserAgent                = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15";

                PersonalName name = new PersonalName();
                name.FirstName     = "Wile";
                name.Surname       = "Coyote";
                name.SurnamePrefix = "E.";
                name.Title         = "Mr.";

                PersonalInformation personalInformation = new PersonalInformation();
                personalInformation.DateOfBirth = "19490917";
                personalInformation.Gender      = "male";
                personalInformation.Name        = name;

                Customer customer = new Customer();
                customer.AccountType         = "none";
                customer.BillingAddress      = billingAddress;
                customer.CompanyInformation  = companyInformation;
                customer.ContactDetails      = contactDetails;
                customer.Device              = device;
                customer.Locale              = "en_US";
                customer.MerchantCustomerId  = "1234";
                customer.PersonalInformation = personalInformation;

                OrderInvoiceData invoiceData = new OrderInvoiceData();
                invoiceData.InvoiceDate   = "20140306191500";
                invoiceData.InvoiceNumber = "000000123";

                OrderReferences references = new OrderReferences();
                references.Descriptor        = "Fast and Furry-ous";
                references.InvoiceData       = invoiceData;
                references.MerchantOrderId   = 123456L;
                references.MerchantReference = "AcmeOrder0001";

                PersonalName shippingName = new PersonalName();
                shippingName.FirstName = "Road";
                shippingName.Surname   = "Runner";
                shippingName.Title     = "Miss";

                AddressPersonal address = new AddressPersonal();
                address.AdditionalInfo = "Suite II";
                address.City           = "Monument Valley";
                address.CountryCode    = "US";
                address.HouseNumber    = "1";
                address.Name           = shippingName;
                address.State          = "Utah";
                address.Street         = "Desertroad";
                address.Zip            = "84536";

                Shipping shipping = new Shipping();
                shipping.Address = address;

                IList <LineItem> items = new List <LineItem>();

                AmountOfMoney item1AmountOfMoney = new AmountOfMoney();
                item1AmountOfMoney.Amount       = 2500L;
                item1AmountOfMoney.CurrencyCode = "EUR";

                LineItemInvoiceData item1InvoiceData = new LineItemInvoiceData();
                item1InvoiceData.Description  = "ACME Super Outfit";
                item1InvoiceData.NrOfItems    = "1";
                item1InvoiceData.PricePerItem = 2500L;

                LineItem item1 = new LineItem();
                item1.AmountOfMoney = item1AmountOfMoney;
                item1.InvoiceData   = item1InvoiceData;

                items.Add(item1);

                AmountOfMoney item2AmountOfMoney = new AmountOfMoney();
                item2AmountOfMoney.Amount       = 480L;
                item2AmountOfMoney.CurrencyCode = "EUR";

                LineItemInvoiceData item2InvoiceData = new LineItemInvoiceData();
                item2InvoiceData.Description  = "Aspirin";
                item2InvoiceData.NrOfItems    = "12";
                item2InvoiceData.PricePerItem = 40L;

                LineItem item2 = new LineItem();
                item2.AmountOfMoney = item2AmountOfMoney;
                item2.InvoiceData   = item2InvoiceData;

                items.Add(item2);

                ShoppingCart shoppingCart = new ShoppingCart();
                shoppingCart.Items = items;

                Order order = new Order();
                order.AmountOfMoney = amountOfMoney;
                order.Customer      = customer;
                order.References    = references;
                order.Shipping      = shipping;
                order.ShoppingCart  = shoppingCart;

                CreatePaymentRequest body = new CreatePaymentRequest();
                body.CardPaymentMethodSpecificInput = cardPaymentMethodSpecificInput;
                body.Order = order;

                try
                {
                    CreatePaymentResponse response = await client.Merchant("merchantId").Payments().Create(body);
                }
                catch (DeclinedPaymentException e)
                {
                    HandleDeclinedPayment(e.CreatePaymentResult);
                }
                catch (ApiException e)
                {
                    HandleApiErrors(e.Errors);
                }
            }
#pragma warning restore 0168
        }
        public static void RegisterOld(Models.Input <WalletProfile> obj)
        {
            PayitMerchantsnWalletsEntities db = new PayitMerchantsnWalletsEntities();
            var isWalletExist = (from a in db.Customers
                                 join b in db.CustomerDevices on a.ID equals b.CustomerID
                                 where a.MobileNo == obj.input.mobileno && b.DeviceUDID == obj.param.deviceuniqueid
                                 select a).FirstOrDefault();

            if (isWalletExist == null)
            {
                Customer cus = new Customer();

                cus.CountryCode     = string.IsNullOrEmpty(obj.input.countrycode) ? "" : obj.input.countrycode;
                cus.CustomerCode    = string.IsNullOrEmpty(obj.input.userid) ? "" : obj.input.userid;
                cus.Password        = string.IsNullOrEmpty(obj.input.password) ? "" : obj.input.password;
                cus.MobileNo        = string.IsNullOrEmpty(obj.input.mobileno) ? "" : obj.input.mobileno;
                cus.MobileActivated = false;
                cus.OTP             = 0;
                cus.Email           = string.IsNullOrEmpty(obj.input.email) ? "" : obj.input.email;
                cus.EmailActivated  = false;
                //cus.AppIdentifier="";
                cus.TranDate = DateTime.Now;
                cus.Status   = false;
                db.Customers.Add(cus);
                db.SaveChanges();


                var CID = cus.ID;

                CustomerDevice CusD = new CustomerDevice();

                CusD.CustomerID = CID;
                CusD.DeviceUDID = obj.param.deviceuniqueid;
                CusD.Status     = false;
                CusD.CreatedDae = DateTime.Now;
                db.CustomerDevices.Add(CusD);
                db.SaveChanges();

                var DeviceID = CusD.ID;

                CustomerWallet CusW = new CustomerWallet();
                CusW.CustomerID  = CID;
                CusW.Balance     = 0;
                CusW.CreatedDate = DateTime.Now;
                CusW.Status      = true;

                db.CustomerWallets.Add(CusW);
                db.SaveChanges();

                CustomerOTP CusO = new CustomerOTP();
                CusO.CusomerID       = CID;
                CusO.DeviceID        = DeviceID;
                CusO.WalletServiceID = 1;
                CusO.OTP             = "";
                CusO.CreatedDate     = DateTime.Now;
                CusO.Status          = true;
                CusO.isUsed          = false;
                db.CustomerOTPs.Add(CusO);
                db.SaveChanges();
            }
        }