Example #1
0
        public void CustomerAddAndGet()
        {
            Customer c = new Customer("Olka", "Nowak ", "O7");

            Assert.AreEqual(repository.GetAllCustomersNumber(), 3);
            repository.AddCustomer(c);
            Assert.AreEqual(repository.GetAllCustomersNumber(), 4);
            Customer temp = repository.GetCustomer("O7");

            Assert.AreEqual(temp, c);
        }
        public async Task <bool> Handle(AddCustomerCommand request, CancellationToken cancellationToken)
        {
            Validate(request);

            var resource = _CustomerRepository.AddCustomer(new Data.Models.Customer()
            {
                CustomerId  = request.CustomerId,
                FirstName   = request.FirstName,
                LastName    = request.LastName,
                DateofBirth = request.DateofBirth
            });

            //EmailHelper.SendEmail("", "*****@*****.**", "Customer details added successfully", "Body Of the email");

            return(true);
        }
        /*
         * Ein Objekt mit 0 Id ist ein neues Objekt und wird über das Repository an den Context angehangen.
         * Ist die Id nicht 0 handelt es sich um ein Update eines vorhandenen Objekts und wird durch die
         * entsprechende Upatefunktion im Repository behandelt.
         */
        public IActionResult UpdateCustomer(Customer customer, Customer original)
        {
            if (string.IsNullOrEmpty(customer.CompanyName))
            {
                ModelState.AddModelError(nameof(customer.CompanyName), "Bitte geben Sie einen Firmennamen an!");
            }

            if (ModelState.GetValidationState(nameof(customer.CompanyName)) == ModelValidationState.Valid)
            {
                if (customer.CustomerId == 0)
                {
                    repository.AddCustomer(customer);
                }
                else
                {
                    repository.UpdateCustomer(customer, original);
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View("EditCustomer", original));
            }
        }
Example #4
0
 public void AddCustomer(Customer customer)
 {
     repository.AddCustomer(customer);
 }
Example #5
0
        public void CreateCustomer(string name, string lastName, Address address)
        {
            var customer = new Customer(name, lastName, address);

            _dataRepository.AddCustomer(customer);
        }
Example #6
0
        public ActionResult PostCustomers(List <Customers> customers)
        {
            _repository.AddCustomer(customers);

            return(NoContent());
        }