Ejemplo n.º 1
0
        public void Add()
        {
            var customer = new CustomerModel(Customer.Name);

            _CustomersService.Add(customer);
            this.Customers.Add(customer);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post(AddCustomerRequest addCustomerRequest, CancellationToken cancellationToken = default)
        {
            var customerDto = _mapper.Map <CustomerDTO>(addCustomerRequest);
            var customer    = await _customersService.Add(customerDto, cancellationToken);

            return(CreatedAtAction(nameof(Get), new { customerId = customer.Id }, customer));
        }
Ejemplo n.º 3
0
        public IHttpActionResult Post(Customer customer)
        {
            customersService.Add(customer);

            // Created($"http://localhost:52879/api/customers/{customer.Id}", customer);

            return(CreatedAtRoute("DefaultApi", new { id = customer.Id }, customer));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Post(Customer customer)
        {
            customersService.Add(customer);

            await hubContext.Clients.All.SendAsync("Added", customer);

            return(CreatedAtRoute(new { Id = customer.Id }, customer));
        }
Ejemplo n.º 5
0
        private void AddCustomer()
        {
            //this.TextValueName = "zmiana";
            //this.TextValueName = this.SelectedCustomer.Name;
            var customer = new Customer(this.TextValueName, this.TextValueAddress, this.TextValueEmail, this.TextValuePassword);

            _CustomersService.Add(customer);
            this.Customers.Add(customer);
        }
Ejemplo n.º 6
0
        private async Task Add(CustomersActions.Add.Invoke action)
        {
            await Put(new CustomersActions.Add.Request());

            var item = await _customersService.Add(action.Name, action.Email, action.MobileNumber, action.Tags);

            await Put(new CustomersActions.Add.Success {
                Item = item.MapToListItem()
            });
        }
Ejemplo n.º 7
0
        public IActionResult Add(Customers customers)
        {
            var result = _customersService.Add(customers);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public async Task <IActionResult> Create([Bind("Id,FullName")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                await _customersService.Add(customer);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Ejemplo n.º 9
0
        public IActionResult Post(Customer customer)
        {
            if (this.ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            customersService.Add(customer);

            return(CreatedAtRoute(new { customer.Id }, customer));
        }
Ejemplo n.º 10
0
        public IActionResult Post([FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _customerService.Add(customer);

            return(CreatedAtAction("Get", new { id = customer.Id }, customer));
        }
 public ActionResult create(string username, string password, string firstName, string lastName, DateTime dayOfBirth, string email, Boolean gender, Boolean active)
 {
     try
     {
         Customers customers = new Customers
         {
             Username   = username,
             Password   = password,
             FirstName  = firstName,
             LastName   = lastName,
             DayOfBirth = dayOfBirth,
             Email      = email,
             Gender     = gender,
             Active     = active
         };
         _customersService.Add(customers);
         _customersService.SaveChanges();
         return(Ok(customers.Username));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 public IActionResult Register([FromBody] Customer customer)
 {
     customersService.Add(customer);
     return(Ok(new { message = "Спасибо за регистрацию" }));
 }
Ejemplo n.º 14
0
 public void Post([FromBody] ICustomerModel value)
 {
     _customerService.Add(value);
 }
Ejemplo n.º 15
0
 public void Post([FromBody] Customer customer)
 {
     customersService.Add(customer);
 }
Ejemplo n.º 16
0
        public IActionResult Post([FromBody] Customer customer)
        {
            customersService.Add(customer);

            return CreatedAtRoute("GetCustomerLink", new { id = customer.Id }, customer);
        }
Ejemplo n.º 17
0
 public void Save()
 {
     customersService.Add(Customer);
 }