コード例 #1
0
 private void Customers_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (((Domain.Customer)Customers.SelectedItem) != null)
     {
         customer = ((Domain.Customer)Customers.SelectedItem);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: mrtony/AspNet-MVC-Samples
 private static void HelloworldBeforeVersion40()
 {
     var customer = new Customer() { FirstName = "Tony", LastName = "Chen", Address = "Taipei", Age = 30 };
     var config = Mapper.CreateMap<Customer, CustomerView>();
     var destination = Mapper.Map<CustomerView>(customer);
     Console.WriteLine("CustomerView內容:{0}", destination.Dump());
 }
コード例 #3
0
 public void Put(Customer input)
 {
     input.ValidateNotNullParameter("customer");
     this.Name = input.Name;
     this.ContactInfo = input.ContactInfo;
     this.PreferredCommunicationMethod = input.PreferredCommunicationMethod;
 }
コード例 #4
0
        private void ButtonCreateCustomer_Click(object sender, RoutedEventArgs e)
        {
            Domain.Customer  customer = new Domain.Customer();
            WindowShowDialog wsd      = new WindowShowDialog();

            customer.CompanyName = TextBoxCompanyName.Text.ToString();

            if (TextBoxCustomerAddress != null && TextBoxCustomerTelephone != null && TextBoxCustomerZip != null && TextBoxCustomerTelephone != null && TextBoxCustomerEmail != null)
            {
                customer.CompanyName       = TextBoxCompanyName.Text;
                customer.CustomerEmail     = TextBoxCustomerEmail.Text;
                customer.CustomerAddress   = TextBoxCustomerAddress.Text;
                customer.CustomerTelephone = TextBoxCustomerTelephone.Text;
                customer.CustomerZip       = TextBoxCustomerZip.Text;
                customer.CustomerTown      = TextBoxCustomerTown.Text;

                customerRepository.AddCustomer(customer);
                wsd.LabelShowDialog.Content = "Kunden blev tilføjet";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Muligvis tommefelter";
                wsd.ShowDialog();
            }
        }
コード例 #5
0
        public WindowEditOrder(Order order)
        {
            InitializeComponent();
            WindowProductAmount.eventSendProductAmount += WindowProductAmount_eventSendProductAmount;

            this.order                 = order;
            TextBoxCustomer.Text       = order.Customer.CompanyName;
            TextBoxTotalPrice.Text     = order.TotalPrice.ToString();
            TextBoxDateOfPurchase.Text = order.DateOfPurchase.ToString();
            customer = order.Customer;
            if (order.Active == true)
            {
                RadioButtonIsOrder.IsChecked = true;
                RadioButtonIsOffer.IsEnabled = false;
            }
            else
            {
                RadioButtonIsOffer.IsChecked = true;
                Orderlines.IsEnabled         = true;
            }

            Update();

            WindowPickCustomer.eventSendList += WindowPickCustomer_eventSendList;
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: PhilG112/banking-app
        static void Main(string[] args)
        {
            var db = new DomainContext();

            var customer = new Customer("matt", "Matthew", "Smith");

            var savings = customer.RegisterSavingsAccount(500m);
            var loan = customer.RegisterLoanAccount(1000m);

            Console.WriteLine("Savings: {0:c}", savings.Balance);
            Console.WriteLine("Loan: {0:c}", loan.Balance);
            Console.WriteLine("Equity: {0:c}", customer.Equity);

            var savingsDebit = savings.Debit(100m, "$50 Deposit");
            var loanDebit = loan.Debit(100m, "$50 Repayment");
            var savingCredit = savings.Credit(250m, "$50 Withdrawal");

            try
            {
                loan.Credit(10m, "Invalid loan extension attempt");
            }
            catch(BusinessRuleException ex)
            {
                Console.WriteLine(ex.Message);
            }

            db.People.Add(customer);
            db.SaveChanges();
        }
コード例 #7
0
        public void setup()
        {
            Mongo mongo = MongoTestHelper.create_new_database_connection();

            mongo.Database.DropCollection(typeof (Customer).Name);

            _customer = new Customer();
            mongo.GetCollection<Customer>().Insert(_customer);
        }
コード例 #8
0
        private void ButtonSearchOrdre_Click(object sender, RoutedEventArgs e)
        {
            Order order = new Order();

            Domain.Customer  customer = new Domain.Customer();
            WindowShowDialog wsd      = new WindowShowDialog();

            if (double.TryParse(TextBoxOrderID.Text, out double resultOrderID) || (double.TryParse(TextBoxCustomer.Text, out double resultCustomer) || double.TryParse(TextBoxTotalPrice.Text, out double resultTotalPrice) || DatePickerDateOfPurchase.SelectedDate != null))
            {
                if (double.TryParse(TextBoxOrderID.Text, out resultOrderID) == false)
                {
                    order.OrderID = 0;
                }
                else
                {
                    order.OrderID = int.Parse(TextBoxOrderID.Text);
                }

                if (double.TryParse(TextBoxCustomer.Text, out resultCustomer) == false)
                {
                    order.Customer            = new Domain.Customer();
                    order.Customer.CustomerID = 0;
                }
                else
                {
                    order.Customer = customer.GetCustomer(int.Parse(TextBoxCustomer.Text));
                }

                if (double.TryParse(TextBoxTotalPrice.Text, out resultTotalPrice) == false)
                {
                    order.TotalPrice = 0;
                }
                else
                {
                    order.TotalPrice = double.Parse(TextBoxTotalPrice.Text);
                }

                if (DatePickerDateOfPurchase.SelectedDate == null)
                {
                    order.DateOfPurchase = new DateTime(1973, 1, 1, 12, 0, 0);
                }
                else
                {
                    order.DateOfPurchase = DateTime.Parse(DatePickerDateOfPurchase.Text);
                }

                eventSendList(orderRepository.DisplaySpecificOrders(order));
                this.Close();
            }

            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Order nummer', 'Kunde', 'Samlet pris' eller 'Pakke dato'";
                wsd.ShowDialog();
            }
        }
コード例 #9
0
        public void insert_customer()
        {
            var customer = new Customer
                               {
                                   Name = "Han Solo"
                               };
            _mongo.GetCollection<Customer>().Insert(customer);

            _mongo.GetCollection<Customer>().Count().ShouldBe(1);
        }
コード例 #10
0
        public void read_customer()
        {
            var customer = new Customer
                               {
                                   Name = "Han Solo"
                               };
            _mongo.GetCollection<Customer>().Insert(customer);

            new MongoQuery<Customer>(_provider).First().Name.ShouldBe("Han Solo");
        }
コード例 #11
0
        public SavingsAccount(long accountNumber, double initialAmount, Customer accountOwner)
        {
            if (!AccountUtil.ValidAccountNumber(accountNumber))
            {
                throw new ArgumentException("AccountNumber");
            }

            this.accountNumber = accountNumber;
            this.amount = initialAmount;
            this.accountOwner = accountOwner;
        }
コード例 #12
0
 public WindowEditCustomer(int customerID)
 {
     InitializeComponent();
     customer = customerRepository.DisplayCustomer(customerID);
     TextBoxCompanyName.Text       = customer.CompanyName;
     TextBoxCustomerEmail.Text     = customer.CustomerEmail;
     TextBoxCustomerAddress.Text   = customer.CustomerAddress.ToString();
     TextBoxCustomerTelephone.Text = customer.CustomerTelephone.ToString();
     TextBoxCustomerZip.Text       = customer.CustomerZip.ToString();
     TextBoxCustomerTown.Text      = customer.CustomerTown.ToString();
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: mrtony/AspNet-MVC-Samples
        /// <summary>
        /// 最基本的應用: 將Customer映射到CustomerView
        /// </summary>
        private static void Helloworld1Version50()
        {
            var customer = new Customer() {FirstName = "Tony", LastName = "Chen", Address = "Taipei", Age = 30};
            var config = new MapperConfiguration(cfg => cfg.CreateMap<Customer, CustomerClone>());
            var mapper = config.CreateMapper();

            var destination = mapper.Map<CustomerClone>(customer);
            Console.WriteLine("------------------\nAutomapper helloworld範例:\n---------------\n");
            Console.WriteLine("來源:CustomerView內容:{0}", customer.Dump());
            Console.WriteLine("目的:CustomerView內容:{0}", destination.Dump());
        }
コード例 #14
0
        public ActionResult Registration(Customer user)
        {
            user.ModifiedDate = DateTime.Now; // текущее время
            user.NameStyle = false;
            user.rowguid = Guid.NewGuid();
            user.PasswordHash = Helpers.SecurityHelper.Hash(user.PasswordSalt);
            user.PasswordSalt = user.PasswordSalt;

            _repository.SaveToUser(user);

            return RedirectToAction("List", "Product");
        }
コード例 #15
0
 public ActionResult Create(Create model)
 {
     if (ModelState.IsValid)
     {
         var customer = new Domain.Customer(model.UserName, model.FirstName, model.LastName);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     else
     {
         return View(model);
     }
 }
コード例 #16
0
        public ActionResult EditProfile(Customer customer)
        {
            var user = AuthHelper.GetUser(HttpContext, _userRepository);
            if (user != null)
            {
                customer.ModifiedDate = DateTime.Now;
                customer.PasswordHash = SecurityHelper.Hash(user.PasswordSalt);
                customer.Title = string.Empty;

                _userRepository.SaveToUser(customer);
            }
            return RedirectToAction("List", "Product");
        }
コード例 #17
0
        public void CreateOrder(Domain.Customer customer, Product product)
        {
            using (_bus)
            {
                _bus.Subscribe <OrderReply>("Customer" + customer.Id, ProcessOrder, x => x.WithTopic(customer.Id));
                Console.WriteLine("Subscribed");
                _bus.Publish <BaseOrder>(new BaseOrder(_count++, product, customer));

                lock (this)
                {
                    Monitor.Wait(this);
                }
            }
        }
コード例 #18
0
        public void delete_customer()
        {
            var customer = new Customer
                               {
                                   Name = "Han Solo"
                               };
            _mongo.GetCollection<Customer>().Insert(customer);

            Customer customerToDelete = new MongoQuery<Customer>(_provider).First();

            _mongo.GetCollection<Customer>().Delete(customerToDelete);

            _mongo.GetCollection<Customer>().Count().ShouldBe(0);
        }
コード例 #19
0
        public void AddCustomer(Customer customer)
        {
            var customerService = new CustomerMethods();

            var newCustomer = new Domain.Customer
            {
                Id        = customer.Id,
                Firstname = customer.Firstname,
                Lastname  = customer.Lastname,
                Telephone = customer.Telephone,
                Email     = customer.Email
            };

            customerService.Add(newCustomer);
        }
コード例 #20
0
        public void RemoveCustomer(Customer customer)
        {
            CustomerMethods customerService = new CustomerMethods();

            var removedCustomer = new Domain.Customer
            {
                Id        = customer.Id,
                Firstname = customer.Firstname,
                Lastname  = customer.Lastname,
                Telephone = customer.Telephone,
                Email     = customer.Email
            };

            customerService.Remove(removedCustomer);
        }
コード例 #21
0
        public CheckingAccount(long accountNumber,
                               double initialAmount,
                               double creditLimit,
                               Customer accountOwner)
        {
            if (!AccountUtil.ValidAccountNumber(accountNumber))
            {
                throw new ArgumentException();
            }

            this.accountNumber = accountNumber;
            this.amount = initialAmount;
            this.creditLimit = creditLimit;
            this.accountOwner = accountOwner;
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: mrtony/AspNet-MVC-Samples
        /// <summary>
        /// Custom value resolvers : https://github.com/AutoMapper/AutoMapper/wiki/Custom-value-resolvers
        /// 建立Resolver處理映射到目的物件時, 將來源物件做處理後再映射到目的物件.
        /// 這個範例是將來源物件的FirstName+LastName後, 映射到目的物件的Name
        /// </summary>
        private static void ValueResolverTest()
        {
            var customer = new Customer() { FirstName = "Tony", LastName = "Chen", Address = "Taipei", Age = 30 };
            var config = new MapperConfiguration(cfg => cfg.CreateMap<Customer, CustomerView>()
                .ForMember(dest => dest.Name, opt => opt.ResolveUsing<CustomerView>()));
            var mapper = config.CreateMapper();

            //驗證: 如果0個field被mapping到目的地, 就會發生assert
            config.AssertConfigurationIsValid();

            var destination = mapper.Map<CustomerView>(customer);
            Console.WriteLine("------------------\nResolver處理映射到目的物件範例:\n---------------\n");
            Console.WriteLine("來源:CustomerView內容:{0}", customer.Dump());
            Console.WriteLine("目的:CustomerView內容(經過resolver):{0}", destination.Dump());
        }
コード例 #23
0
        public void update_customer()
        {
            var customer = new Customer
                               {
                                   Name = "Han Solo"
                               };
            _mongo.GetCollection<Customer>().Insert(customer);

            Customer customerToUpdate = new MongoQuery<Customer>(_provider).First();
            customerToUpdate.Name = "Luke Skywalker";

            _mongo.GetCollection<Customer>().Save(customerToUpdate);

            _mongo.GetCollection<Customer>().Count().ShouldBe(1);
            new MongoQuery<Customer>(_provider).First().Name.ShouldBe("Luke Skywalker");
        }
コード例 #24
0
 public Issue(string name, int websiteId, int priority, TypeOfIssue type, string description, Customer customer = null)
 {
     this.Id = ++IdCount;
     this.Name = name;
     this.DateRaised = DateTime.Now;
     this.WebsiteId = websiteId;
     this.Priority = priority;
     this.IssueType = type;
     this.Description = description;
     this.AffectedBrowsers = new HashSet<WebBrowser>();
     this.AffectedCustomers = new HashSet<Customer>();
     this.Notes = new List<Notes>();
     if (customer != null)
     {
         this.AffectedCustomers.Add(customer);
     }
     this.Open = true;
 }
コード例 #25
0
        private void ButtonSearchCustomer_Click(object sender, RoutedEventArgs e)
        {
            Domain.Customer  customer = new Domain.Customer();
            WindowShowDialog wsd      = new WindowShowDialog();

            if (TextBoxCompanyName != null || TextBoxCustomerEmail != null || TextBoxCustomerAddress != null || TextBoxCustomerTown != null || TextBoxCustomerZip != null || TextBoxCustomerTelephone != null)
            {
                customer.CompanyName       = TextBoxCompanyName.Text.ToString();
                customer.CustomerEmail     = TextBoxCustomerEmail.Text.ToString();
                customer.CustomerAddress   = TextBoxCustomerAddress.Text.ToString();
                customer.CustomerTown      = TextBoxCustomerTown.Text.ToString();
                customer.CustomerZip       = TextBoxCustomerZip.Text.ToString();
                customer.CustomerTelephone = TextBoxCustomerTelephone.Text.ToString();

                eventSendList(customerRepository.DisplaySpecificCustomers(customer));

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Firma navn', 'Adresse', 'By', 'Postnr' eller 'Telefon'";
                wsd.ShowDialog();
            }
        }
コード例 #26
0
 public Ticket(TicketInformation ticketInfo, Customer contactInfo, Feature feature)
 {
     this.TicketInfo = ticketInfo;
     this.FeatureToFix = feature;
     this.ContactInfo = contactInfo;
 }
コード例 #27
0
        public static bool PutTicket(
            int tid,
            Dmn.Priority prio,
            string devnotes,
            string name,
            string email,
            string phoneNumber,
            string message,
            string twitterHandle,
            string facebookName,
            string contactMethod,
            string url,
            string website,
            string webpage,
            List<Dto.Developer> devs,
            string teamName,
            int teamId,
            bool isBroken,
            string featureName)
        {
            Dmn.Ticket ticket = Dmn.DummyDatabase.Tickets.FirstOrDefault(i => i.TicketInfo.Id == tid);
            if (ticket == null)
            {
                return false;
            }

            List<Dmn.Developer> dmnDevs = new List<Domain.Developer>();

            foreach (Dto.Developer dev in devs)
            {
                dmnDevs.Add(new Dmn.Developer(dev.Name, dev.PhoneNumber, dev.Email));
            }

            Dmn.WebLocation location = new Dmn.WebLocation(url, website, webpage);
            Dmn.DeveloperTeam team = new Dmn.DeveloperTeam(teamId, dmnDevs, teamName);
            Dmn.TicketInformation info = new Dmn.TicketInformation(tid, prio, devnotes);
            Dmn.Customer customer = new Dmn.Customer(name, email, phoneNumber, message, twitterHandle, facebookName, contactMethod);
            Dmn.Feature feature = new Dmn.Feature(location, team, isBroken, featureName);

            ticket.Update(info, customer, feature);
            return true;
        }
コード例 #28
0
        public static Dto.Ticket PostTicket(
            Dmn.Priority prio,
            string devnotes,
            string name,
            string email,
            string phoneNumber,
            string message,
            string twitterHandle,
            string facebookName,
            string contactMethod,
            string url,
            string website,
            string webpage,
            List<Dto.Developer> devs,
            string teamName,
            int teamId, 
            bool isBroken, 
            string featureName)
        {
            List<Dmn.Developer> dmnDevs = new List<Domain.Developer>();

            foreach (Dto.Developer dev in devs)
            {
                dmnDevs.Add(new Dmn.Developer(dev.Name, dev.PhoneNumber, dev.Email));
            }
            Dmn.WebLocation location = new Dmn.WebLocation(url, website, webpage);
            Dmn.DeveloperTeam team = new Dmn.DeveloperTeam(teamId, dmnDevs, teamName);
            Dmn.TicketInformation info = new Dmn.TicketInformation(prio, devnotes);
            Dmn.Customer customer = new Dmn.Customer(name, email, phoneNumber, message, twitterHandle, facebookName, contactMethod);
            Dmn.Feature feature = new Dmn.Feature(location, team, isBroken, featureName);

            Dmn.Ticket ticket = new Dmn.Ticket(info, customer, feature);
            Dmn.DummyDatabase.Tickets.Add(ticket);
            return TicketConverter.ToDto(ticket);
        }
コード例 #29
0
ファイル: WindowAddOrder.xaml.cs プロジェクト: math4249/ERP
 void WindowPickCustomer_eventSendList(Domain.Customer customer)
 {
     TextBoxCustomer.Text = customer.CompanyName;
     order.Customer       = customer;
 }
コード例 #30
0
 public static Dto.Customer PostCustomer(string name, string email, string phoneNumber, string message, string twitterHandle, string facebookName, string contactMethod)
 {
     Dmn.Customer cust = new Dmn.Customer(name, email, phoneNumber, message, twitterHandle, facebookName, contactMethod);
     Dmn.DummyDatabase.Customers.Add(cust);
     return CustomerConverter.ToDto(cust);
 }
コード例 #31
0
 void WindowPickCustomer_eventSendList(Domain.Customer items)
 {
     TextBoxCustomer.Text = items.CompanyName;
     order.Customer       = items;
 }