Exemplo n.º 1
0
        public async Task AddCustomerAsync(Customer customer)
        {
            var new_customer = new CustomerEntity
            {
                FirstName = customer.FirstName,
                LastName  = customer.LastName,
                Email     = customer.Email
            };

            await _context.Customers.AddAsync(new_customer);

            await _context.SaveChangesAsync();

            _logger.LogInformation($"Added Customer {customer.FirstName} {customer.LastName} to the database");
        }
Exemplo n.º 2
0
        public async Task AddAsync(BusinessLogic.User user)
        {
            if (_context.Users.Any(u => u.Email == user.Email))
            {
                throw new Exception("User already exists");
            }

            var dataUser = new User()
            {
                UserID    = user.UserID,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Email     = user.Email,
                Password  = user.Password
            };

            _context.Add(dataUser);
            await _context.SaveChangesAsync();
        }