Exemple #1
0
        public IHttpActionResult Get(string code)
        {
            var customer = customersService.Get(code);

            if (customer == null)
            {
                return(NotFound());
            }

            return(Ok(customer));
        }
        public IActionResult Get(int id)
        {
            var customer = customersService.Get(id);

            if (customer == null)
            {
                return(NotFound());
            }


            return(Ok(customer));
        }
Exemple #3
0
        public void Load()
        {
            Customers = new ObservableCollection <Customer>(customersService.Get());


            SelectedCustomer = Customers.First();
        }
Exemple #4
0
 private void Load()
 {
     Customers = new ObservableCollection <CustomerModel>(_CustomersService.Get());  //implementacja klasy informującej listę o konieczności zmiany
     // Customers = new ObservableCollection<CustomerModel>();  //implementacja klasy informującej listę o konieczności zmiany
     //sdffsdfsdfsd
     this.TextValueName = "abc";
 }
Exemple #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Initialize();

            ICustomersService customerService = MyServiceProvider.GetServiceProvider().GetService <ICustomersService>();

            foreach (Customer customer in customerService.Get())
            {
                Console.WriteLine(customer);
            }

            Console.WriteLine("-------------------------------------------------------");
            List <Customer> foundCustomers = customerService.SearchByCountry("Poland");

            foreach (Customer customer in foundCustomers)
            {
                Console.WriteLine(customer);
            }
            Console.WriteLine("-------------------------------------------------------");

            //GenerateItems();

            //ICustomersService fakeCustomerService = new FakeCustomerService();
            //List<Customer> customers = fakeCustomerService.Get();
            //
            //foreach (Customer customer in customers)
            //{
            //    customerService.Add(customer);
            //}
            // FakeApproach();
        }
        private static void LinqTest(ICustomersService customersService)
        {
            var customers = customersService.Get();

            var query = customers.GroupBy(c => c.FirstName)
                        .Select(g => new { FirstName = g.Key, Qty = g });
        }
Exemple #7
0
        public IActionResult Get()
        {
            var customers = customersService.Get();

            if (this.User.Identity.IsAuthenticated)
            {
            }

            // if (User.HasClaim(c=>c.))

            if (this.User.IsInRole("Administrator"))
            {
            }



            return(Ok(customers));
        }
Exemple #8
0
        public MockOrdersService(ICustomersService customersService, IProductsService productsService)
        {
            var order1 = new Order
            {
                CreateDate  = DateTime.Now,
                OrderNumber = "ZAM 1/2018",
                Customer    = customersService.Get(1),
                Details     = new List <OrderDetail>
                {
                    new OrderDetail
                    {
                        Product   = productsService.Get(1),
                        Quantity  = 10,
                        UnitPrice = 100
                    },
                    new OrderDetail
                    {
                        Product   = productsService.Get(2),
                        Quantity  = 2,
                        UnitPrice = 400
                    }
                }
            };

            orders.Add(order1);

            var order2 = new Order
            {
                CreateDate  = DateTime.Now,
                OrderNumber = "ZAM 2/2018",
                Customer    = customersService.Get(2),
                Details     = new List <OrderDetail>
                {
                    new OrderDetail
                    {
                        Product   = productsService.Get(2),
                        Quantity  = 10,
                        UnitPrice = 100
                    }
                }
            };

            orders.Add(order2);
        }
        public async Task <ActionResult <CustomerDto> > Get(int id)
        {
            var client = await _customersService.Get(id);

            if (client == null)
            {
                return(NotFound());
            }

            return(Ok(client));
        }
 public ActionResult getCustomer(string username)
 {
     try
     {
         Customers            customers            = _customersService.Get(_ => _.Username == username);
         CustomerGetViewModel customerGetViewModel = new CustomerGetViewModel
         {
             Username   = customers.Username,
             FirstName  = customers.FirstName,
             LastName   = customers.LastName,
             DayOfBirth = customers.DayOfBirth,
             Email      = customers.Email,
             Active     = customers.Active,
             Gender     = customers.Gender,
         };
         return(Ok(customerGetViewModel));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public IActionResult Get()
        {
            //if (!this.User.Identity.IsAuthenticated)
            //{
            //    return BadRequest();
            //}

            logger.LogInformation("Get Customers");

            if (this.User.IsInRole("Boss"))
            {
            }

            var customers = customersService.Get();

            return(Ok(customers));
        }
Exemple #12
0
        private void GenerateMockData()
        {
            _orders = new List <Order>();

            var rounds = _random.Next(10, 30);

            for (var i = 0; i < rounds; i++)
            {
                var order = new Order
                {
                    Id       = i + 1,
                    Customer = _customersService.Get(_random.Next(1, 10)),
                    Details  = _orderDetailsService.Get(null)
                };

                _orders.Add(order);
            }
        }
Exemple #13
0
 public ActionResult <IEnumerable <Customer> > Get()
 {
     return(Ok(customersService.Get()));
 }
 private void Load()
 {
     Customers = customersService.Get();
 }
        static void Main(string[] args)
        {
            WriteLine("Hello World!");

            // Install-Package Microsoft.Extensions.Configuration
            // Install-Package Microsoft.Extensions.Configuration.FileExtensions
            // Install-Package Microsoft.Extensions.Configuration.Json
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            WriteLine(configuration.GetConnectionString("ShopConnection"));

            // Install-Package Microsoft.Extensions.DependencyInjection
            ServiceCollection services = new ServiceCollection();

            services.AddTransient <ICustomersService, DbCustomersService>();
            services.AddTransient <IItemsService, DbItemsService>();

            // Install-Package Microsoft.EntityFrameworkCore.SqlServer
            services.AddDbContext <ShopContext>(options => options
                                                .UseSqlServer(configuration.GetConnectionString("ShopConnection")));

            ServiceProvider serviceProvider = services.BuildServiceProvider();

            // ICustomersService customersService = new FakeCustomersService();
            ICustomersService customersService = serviceProvider.GetService <ICustomersService>();

            var query = customersService.Get();


            var           items        = new FakeItemsService().Get();
            IItemsService itemsService = serviceProvider.GetService <IItemsService>();

            itemsService.AddRange(items);

            var customers = customersService.Search(new CustomerSearchCriteria {
                Country = "Poland"
            });

            var newCustomers = new FakeCustomersService().Get();

            foreach (var newCustomer in newCustomers)
            {
                customersService.Add(newCustomer);
            }


            LinqTest(customersService);


            // Uwaga: W przypadku float/double mimo dzielenia przez zero nie pojawi się błąd,
            // lecz przyjmie wartość infinity!
            double result = 2d / 0;

            Console.WriteLine(result);

            // DelegateTest();

            // Typ anonimowy
            // AnonymouseTypeTest();

            Customer customer = GetCustomer();

            var order = new Order(customer);

            Item item;

            do
            {
                item = GetItem();
                int quantity = GetQuantity();

                OrderDetail detail = new OrderDetail(item, quantity);

                order.AddDetail(detail);
            } while (item != null);

            // EnumTest(order);

            // ExtensionsMethodTest();

            GetCustomersTest();

            // GetItemsTest();

            #region Variable vs Reference Types

            VariableTest();
            StringTest();
            ReferenceTest();

            #endregion


            Helper.GreaterThanZero(100);
        }
Exemple #16
0
 private void Load()
 {
     Customers = new ObservableCollection <Customer>(_customersService.Get());
 }
Exemple #17
0
 public ICustomerModel Get(int id)
 {
     return(_customerService.Get(id));
 }
Exemple #18
0
        public IActionResult Get()
        {
            var customers = customersService.Get();

            return(Ok(customers));
        }
 public IActionResult Get()
 {
     return(Ok(customersService.Get()));
 }
        public CustomersViewModel(ICustomersService customersService)
        {
            this.customersService = customersService;

            this.Customers = customersService.Get();
        }
Exemple #21
0
 private void Load()
 {
     Customers = new ObservableCollection <CustomerModel>(_CustomersService.Get());  //implementacja klasy informującej listę o konieczności zmiany
 }