예제 #1
0
        public string ToString_AdvancedCustomerFormats_PositiveTest(string format, IFormatProvider formatProvider)
        {
            AdvancedCustomer ce = new AdvancedCustomer();

            Customer.Customer c = new Customer.Customer("Jeffrey Richter", "+1 (425) 555-0100", 1000000);
            return(ce.Format(format, c, formatProvider));
        }
        private void MemberService_Saved(IMemberService sender, global::Umbraco.Core.Events.SaveEventArgs <IMember> e)
        {
            foreach (var member in e.SavedEntities)
            {
                if (string.IsNullOrEmpty(member.GetValue <string>(GlobalSettings.UmbracoSettings.MemberIdPropertyAlias)))
                {
                    var customer = new Customer.Customer()
                    {
                        roles = new List <int>()
                        {
                            3
                        },
                        FirstName = member.Name,
                        LastName  = "",
                        Password  = Guid.NewGuid().ToString(),
                        Email     = member.Email
                    };

                    string customerId;

                    if (string.IsNullOrEmpty(_userContext.CustomerId()))
                    {
                        customerId = _nopService.CreateCustomer(customer);
                        _userContext.SetCustomerId(int.Parse(customerId));
                    }
                    else
                    {
                        var nopCustomerId = _userContext.CustomerId();
                        customerId = _nopService.UpdateCustomer(customer, nopCustomerId);
                    }

                    member.SetValue(GlobalSettings.UmbracoSettings.MemberIdPropertyAlias, customerId);
                }
            }
        }
        private void Costumer_Click(object sender, RoutedEventArgs e)
        {
            var Customer = new Customer.Customer();

            Customer.Show();
            this.Close();
        }
예제 #4
0
        public void Delete(Customer.Customer cus)
        {
            try
            {
                using (SqlConnection con = _connect.ConnectToDatabase())
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection     = con;
                        command.CommandType    = CommandType.StoredProcedure;
                        command.CommandTimeout = 1200;
                        command.CommandText    = @"dbo.sp_Delete_Customer";

                        command.Parameters.AddWithValue(@"id", cus.ID);

                        con.Open();
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                _write.Write(ex.ToString());
                throw ex;
            }
        }
        public float GetPrice(Customer.Customer customer)
        {
            if (customer.IsGold)
            {
                return(ListPrice * 0.7f);
            }

            return(ListPrice);
        }
예제 #6
0
        public void Sell(Customer.Customer customer)
        {
            customer.AddItems(_product);
            string transaction = customer.GetName() + " bought item #" + _itemNr + " " + customer.GetItemName() + "\nFrom: " + _name + "\n";

            Console.WriteLine(transaction.PadLeft(Console.WindowWidth));
            customer.AddTotalItems();
            Items.RemoveAt(0);
        }
예제 #7
0
        public ContentResult Create()
        {
            var customer = new Customer.Customer()
            {
                CustomerName = "shengjie"
            };

            _customerAppService.CreateCustomer(customer);

            return(Content($"The shopping cart number of customer is {customer.ShoppingCart.Id}"));
        }
        async Task CustomersProducer(ConcurrentQueue <ICustomer> customersQueue, CancellationToken token)
        {
            do
            {
                await Task.Delay(1000); // one second delay between customers creation

                ICustomer customer = new Customer.Customer();

                customersQueue.Enqueue(customer);
            }while (!token.IsCancellationRequested);
        }
예제 #9
0
 public void AddCustomer(Customer.Customer customer)
 {
     if (customer != null)
     {
         this.customers.Add(customer);
     }
     else
     {
         throw new System.Exception("This is not a valid customer!");
     }
 }
예제 #10
0
        private async Task CustomerSelected(Customer.Customer arg)
        {
            //Populate the fields
            Fields.Single(f => f.Type == FieldType.FirstName).Value = arg.FirstName;
            Fields.Single(f => f.Type == FieldType.LastName).Value  = arg.LastName;
            Fields.Single(f => f.Type == FieldType.Email).Value     = arg.Email;
            Fields.Single(f => f.Type == FieldType.Phone).Value     = arg.Phone;
            Fields.Single(f => f.Type == FieldType.Notes).Value     = arg.Notes;

            ShowCustomerForm      = true;
            ShowNoCustomerWarning = false;
            ShowAddButton         = false;
            ShowSaveButton        = true;
        }
        public string UpdateCustomer(Customer.Customer customer, string id)
        {
            string jsonCustomer = JsonConvert.SerializeObject(new
            {
                customer = customer
            });

            string jsonUrl = $"/api/customers/{id}";

            object productData = _nopApiClient.Put(jsonUrl, jsonCustomer);

            var jo = JObject.Parse(productData.ToString());

            var data = jo["customers"][0]["id"].ToString();

            return(data);
        }
예제 #12
0
        static void Main(string[] args)
        {
            Customer.Customer obj = new Customer.Customer();
            obj.CustomerCode = "CustomerCode";
            obj.CustomerName = "CustomerName";
            obj.Age          = 35;


            /* The end user should not be exposed to Validate and CreateDBObjects functions.
             * We are complicating his life.
             * So, we can make these two functions are private to make these functions not exposed to end user
             *
             */
            // obj.Validate();
            // obj.CreateDBObjects();
            obj.AddCustomerDataIntoDb();
        }
예제 #13
0
        public void CreateTemporalNopCustomer()
        {
            var customer = new Customer.Customer()
            {
                roles = new List <int>()
                {
                    3
                },
                FirstName = "Temp",
                LastName  = "Temp",
                Password  = Guid.NewGuid().ToString(),
                Email     = "*****@*****.**"
            };

            var customerId = _nopService.CreateCustomer(customer);

            _userContext.SetCustomerId(int.Parse(customerId));
        }
        /// <summary>
        /// Converts Customer object into string representation using additional formats.
        /// </summary>
        /// <param name="format">Format of string representation.</param>
        /// <param name="obj">Customer object for converting.</param>
        /// <param name="formatProvider">Format provider.</param>
        /// <returns>String representation of the customer.</returns>
        public string Format(string format, object obj, IFormatProvider formatProvider)
        {
            Customer.Customer customer = obj as Customer.Customer;
            if (customer is null)
            {
                throw new ArgumentNullException($"{nameof(customer)} is null.");
            }

            if (string.IsNullOrEmpty(format))
            {
                format = "1+";
            }

            if (formatProvider is null)
            {
                formatProvider = parentFormatProvider;
            }

            switch (format)
            {
            case "1+":
                return($"Customer record: Name - {customer.Name}, Revenue - {customer.Revenue.ToString("N", NumberFormatInfo.InvariantInfo)}, Phone - {customer.ContactPhone}");

            case "2+":
                return($"Customer record: Phone - {customer.ContactPhone}");

            case "3+":
                return($"Customer record: Name - {customer.Name}, Revenue - {customer.Revenue.ToString("N", NumberFormatInfo.InvariantInfo)}");

            case "4+":
                return($"Customer record: Name - {customer.Name}");

            case "5+":
                return($"Customer record: Revenue - {customer.Revenue}");

            case "6+":
                return($"Customer record: Revenue - {NumberIntoWords((double)customer.Revenue)}");

            default:
                throw new FormatException($"This format {format} is not supported.");
            }
        }
예제 #15
0
        public static void MakePayment(List <Product.Product> products, Customer.Customer customer)
        {
            Payment payment = new Payment();

            payment.Customer = customer;
            payment.Products = products;
            int amount = 0;

            foreach (Product.Product product in products)
            {
                amount += product.ProductPrice;
            }
            if (customer.GetMoney() < amount)
            {
                payment.Status = PaymentStatus.Error;
                return;
            }
            customer.Withdraw(amount);
            payment.Status = PaymentStatus.Success;
            customer.Payments.Add(payment);
        }
예제 #16
0
        public void CreateNopCustomer(IPublishedContent member)
        {
            var memberService = Services.MemberService;

            var currentMember = memberService.GetById(member.Id);

            var customer = new Customer.Customer()
            {
                roles = new List <int>()
                {
                    3
                },
                FirstName = currentMember.Name,
                LastName  = currentMember.Name,
                Password  = Guid.NewGuid().ToString(),
                Email     = currentMember.Email
            };

            var customerId = _nopService.CreateCustomer(customer);

            currentMember.SetValue("NopCustomerId", customerId);

            memberService.Save(currentMember);
        }
예제 #17
0
        public bool IsEligible(Customer.Customer cust, int amount)
        {
            Console.WriteLine("{0} applies for {1:C} loan\n",
                              cust.Name, amount);

            bool eligible = true;

            // Check creditworthyness of applicant

            if (!_bank.HasSufficientSavings(cust, amount))
            {
                eligible = false;
            }
            else if (!_loan.HasNoBadLoans(cust))
            {
                eligible = false;
            }
            else if (!_credit.HasGoodCredit(cust))
            {
                eligible = false;
            }

            return(eligible);
        }
예제 #18
0
 public void ToString_InvalidAdvancedCustomerFormat_ThrowsFormatException()
 {
     Customer.Customer c = new Customer.Customer("Jeffrey Richter", "+1 (425) 555-0100", 1000000);
     NUnit.Framework.Assert.Throws <FormatException>(() => c.ToString("1++", null));
 }
예제 #19
0
 public void GameSale(Games game, Customer.Customer customer, Campaign.Campaigns campaigns)
 {
     Console.WriteLine($"{game.GameName} İsimli oyunu {customer.Name}' {campaigns.CampaignName} Adlı Kampanyayı Kullanarak {_indirimFiyati} İndirim İle Satın Aldı! (İndirimsiz Hali:{game.GamePrice})  Haydi Hemen Oynamaya Başla!");
 }
 public bool HasSufficientSavings(Customer.Customer c, int amount)
 {
     Console.WriteLine("Check bank for " + c.Name);
     return(true);
 }
예제 #21
0
 public bool HasNoBadLoans(Customer.Customer c)
 {
     Console.WriteLine("Check loans for " + c.Name);
     return(true);
 }
예제 #22
0
 public ShoppingCart(Customer.Customer customer)
 {
     Products = new List <Product.Product>();
     Customer = customer;
 }
 public bool HasGoodCredit(Customer.Customer c)
 {
     Console.WriteLine("Check credit for " + c.Name);
     return(true);
 }