Example #1
0
        static void Main(string[] args)
        {
            var         op = new CustomerOperations();
            CustomerDTO c  = new CustomerDTO()
            {
                ID           = 4, Name = "XYZ",
                AddressLine1 = "0000",
                AddressLine2 = "0000"
                , State      = "000000",
                City         = "00000",
                SSNID        = 444989944,
                DOB          = DateTime.Now,
                Active       = true
            };
            long id = op.AddCustomer(c);
            //var a = op.DeleteCustomer(7);
            // AccountDTO acc = new AccountDTO() { Active = true, CustomerId = 8, Type = "Savimngs" };
            // var Aop = new AccountOperations();

            //   var a = Aop.GetActiveAccounts();
            //op.UpdateCustomer(c);

            //var Top = new TransactionOperations();
            //Top.Deposit(3, 500,"Dep");

            //Top.Withdraw(2, 500, "W");

            //Top.Transfer(2,3,1000);

            //   var x = Aop.GetAccountStatement(2,1);
        }
Example #2
0
        // GET: Customer
        public ActionResult Index()
        {
            CustomerOperations customerOperations = new CustomerOperations();
            var customer = customerOperations.GetCustomerData();

            return(View(customer));
        }
Example #3
0
        public SbankenClient(string clientId, string clientSecret)
        {
            _connection = new Connection(clientId, clientSecret);

            Customers = new CustomerOperations(_connection);
            Bank      = new BankOperations(_connection);
        }
        public async Task FindWithIncludesTask()
        {
            // specify which navigation properties to include
            var customer = await CustomerOperations.Get(3, new[]
            {
                "CountryIdentifierNavigation",
                "ContactTypeIdentifierNavigation"
            });

            Assert.IsTrue(
                customer.CountryIdentifierNavigation != null &&
                customer.ContactTypeIdentifierNavigation != null);

            // get customer w/o any navigation properties
            customer = await CustomerOperations.Get(3);

            Assert.AreEqual(customer.CompanyName, "Antonio Moreno Taquería");

            // get customer with all navigation properties
            customer = await CustomerOperations.GetWithAllNavigationProperties(3);

            Assert.IsTrue(
                customer.CountryIdentifierNavigation != null &&
                customer.ContactTypeIdentifierNavigation != null &
                customer.Orders != null &&
                customer.Contact != null);
        }
Example #5
0
        static void Delete(ApplicationDbContext context)
        {
            Customer      customer  = null;
            string        email     = string.Empty;
            StringBuilder sb        = new();
            bool          goodInput = false;
            bool          userFound = false;

            while (!userFound)
            {
                while (!goodInput)
                {
                    Console.Write("Enter customer's to delete email address: ");

                    sb.Append(Console.ReadLine().Trim().ToLower());
                    Regex regex = new(@"\w+\@\w+\.[A-z]+");
                    if (regex.IsMatch(sb.ToString()))
                    {
                        goodInput = true;
                        email     = sb.ToString();
                    }
                    else
                    {
                        Console.WriteLine("Invalid input. Try again.");
                    }
                    sb.Clear();
                }

                customer = CustomerOperations.FindCustomerByEmail(context, email);
                if (!(customer is null))
                {
                    userFound = true;
                }
        public async Task SortCustomerByCompanyNameAscendingTask()
        {
            var customerItems = await CustomerOperations.CustomerSort("CompanyName");

            Assert.AreEqual(customerItems.FirstOrDefault()?.CompanyName,
                            "Alfreds Futterkiste",
                            $"{TestContextInstance.TestName} failed");
        }
        public async Task SortCustomerByCompanyNameDescendingTask()
        {
            var customerItems = await CustomerOperations.CustomerSort("CompanyName", SortDirection.Descending);

            Assert.AreEqual(customerItems.FirstOrDefault()?.CompanyName,
                            "Wolski  Zajazd",
                            $"{TestContextInstance.TestName} failed");
        }
Example #8
0
        static void Main(string[] args)
        {
            Customer customer = new Customer();

            customer.CustomerId        = 1;
            customer.CustomerFırstName = "ALI";
            customer.CustomerLastName  = "VELI";
            customer.CustomerNıckName  = "ALI-1";
            customer.CustomerCıty      = "ARTVIN";
            customer.CustomerAge       = 20;
            Customer customer1 = new Customer();

            customer1.CustomerId        = 2;
            customer1.CustomerFırstName = "AHMET";
            customer1.CustomerLastName  = "MEHMET";
            customer1.CustomerNıckName  = "AHMET-1";
            customer1.CustomerCıty      = "KARS";
            customer1.CustomerAge       = 38;

            Customer customer2 = new Customer();

            customer.CustomerId        = 3;
            customer.CustomerFırstName = "HASAN";
            customer.CustomerLastName  = "HUSEYIN";
            customer.CustomerNıckName  = "HASAN-1";
            customer.CustomerCıty      = "ANTALYA";
            customer.CustomerAge       = 16;

            Game game = new Game();

            game.GameId    = 111;
            game.GameName  = "GAME-1";
            game.GamePrice = 0;

            Game game1 = new Game();

            game1.GameId    = 222;
            game1.GameName  = "GAME-2";
            game1.GamePrice = 1;

            Game game2 = new Game();

            game2.GameId    = 333;
            game2.GameName  = "GAME-3";
            game2.GamePrice = 2;

            CustomerOperations customerOperations = new CustomerOperations();

            customerOperations.CustomerAdd(customer);
            customerOperations.CustomerDelete(customer1);
            customerOperations.CustomerUpdate(customer2);

            GameOperations gameOperatıons = new GameOperations();

            gameOperatıons.GameAdd(game);
            gameOperatıons.GameDelete(game1);
            gameOperatıons.GameUpdate(game2);
        }
Example #9
0
        private async void Form1_Shown(object sender, EventArgs e)
        {
            _customerView            = new BindingListView <CustomerItem>(await CustomerOperations.DemonstrationCustomOrdering());
            dataGridView1.DataSource = _customerView;

            // ReSharper disable once PossibleNullReferenceException
            dataGridView1.Columns["CustomerIdentifier"].Visible = false;
            dataGridView1.ExpandColumns("Name");
        }
Example #10
0
 public CustomerViewModelSecond()
 {
     customerOperationsObj = new CustomerOperations();
     LoadData();
     addCustomerCommand    = new CustomerCommands(Add);
     searchCustomerCommand = new CustomerCommands(Search);
     updateCustomerCommand = new CustomerCommands(Update);
     CurrentCustomer       = new Customer();
 }
        public async Task GenericCustomerFindWithIncludesTask()
        {
            var customer = await CustomerOperations.GenericRepositoryFindWithIncludesAsync(3);

            Assert.IsFalse(customer.CountryIdentifierNavigation == null);
            Assert.IsFalse(customer.ContactTypeIdentifierNavigation == null);
            Assert.IsFalse(customer.Contact == null);
            Assert.IsFalse(customer.Orders == null);
        }
        /* Render */

        public ActionResult Index()
        {
            Account account = base.GetLoginAccount(false);

            if (account == null || !CustomerOperations.CanRender(account))
            {
                return(base.ToLoginPage());
            }
            return(View());
        }
Example #13
0
        //Method to update customer
        public bool UpdateCustomer(Customer cobj)
        {
            bool result = false;

            if (Validate(cobj))
            {
                CustomerOperations co = new CustomerOperations();
                result = co.UpdateCustomer(cobj);
            }
            return(result);
        }
        public async Task Fetch_RanToCompletion()
        {
            var ops        = new CustomerOperations();
            var resultTask = ops.FetchTopCustomers();

            var customers = await resultTask;

            Assert.AreEqual(resultTask.Status, TaskStatus.RanToCompletion);
            Assert.IsNull(resultTask.Exception);
            Assert.IsTrue(customers.All(c => c.Region != CustomerOperations.ProtectedRegion));
        }
Example #15
0
 public Customer SearchCustomer_BLL(int customerID)
 {
     try
     {
         CustomerOperations pd = new CustomerOperations();
         return(pd.SearchCustomer_DAL(customerID));
     }
     catch (TaxiExceptions)
     {
         throw;
     }
 }
Example #16
0
 public DataTable DisplayCustomer_BLL()
 {
     try
     {
         CustomerOperations pd = new CustomerOperations();
         return(pd.DisplayCustomer_DAL());
     }
     catch (TaxiExceptions)
     {
         throw;
     }
 }
Example #17
0
 public bool DeleteCustomer_BLL(int customerID)
 {
     try
     {
         CustomerOperations pd = new CustomerOperations();
         return(pd.DeleteCustomer_DAL(customerID));
     }
     catch (TaxiExceptions)
     {
         throw;
     }
 }
Example #18
0
 public bool UpdateCustomer_BLL(Customer pobj)
 {
     try
     {
         CustomerOperations co = new CustomerOperations();
         return(co.UpdateCustomer_DAL(pobj));
     }
     catch (TaxiExceptions)
     {
         throw;
     }
 }
Example #19
0
 public int AddCustomer_BLL(Customer pobj, Users users)
 {
     try
     {
         CustomerOperations pd = new CustomerOperations();
         return(pd.AddCustomer_DAL(pobj, users));
     }
     catch (TaxiExceptions)
     {
         throw;
     }
 }
Example #20
0
        private void ReloadAllCustomers()
        {
            var customerOperations = new CustomerOperations();

            try
            {
                AllCustomers = new ObservableCollection <CustomerProxy>(customerOperations.GetAllCustomers().Result);
            }
            catch (Exception ex)
            {
                // log
            }
        }
Example #21
0
        public static async Task Main()
        {
            var ops        = new CustomerOperations();
            var resultTask = ops.FetchTopCustomers();

            var customers = await resultTask;

            foreach (var customer in customers)
            {
                Logger.Log($"{customer.Name} ({customer.Region}): {customer.TotalOrders:N0}");
            }
            Console.ReadLine();
        }
Example #22
0
        public void InsertShouldInsertNewRecord()
        {
            var northwindEntities = new NorthwindEntities();
            var customerId        = "AAAAA";

            CustomerOperations.Insert(northwindEntities, customerId, "Test company");

            var customer = CustomerOperations.FindById(northwindEntities, customerId);

            CustomerOperations.Delete(northwindEntities, customerId);

            Assert.AreEqual(customer.CustomerID, customerId);
        }
        public async Task AttachRangeTask()
        {
            var topFiveCustomers = await CustomerOperations.SelectTopFiveCustomersAsync();

            for (int index = 0; index < topFiveCustomers.Count; index++)
            {
                topFiveCustomers[index].CompanyName += "1";
            }

            var success = CustomerOperations.AttachCustomersRange(topFiveCustomers);

            Assert.IsTrue(success);
        }
 public ActionResult CheckInConfirmed(int id)
 {
     CurrentDateTime curr = new CurrentDateTime();
     curr.time = System.DateTime.Now;
     Reservation reservation = db.Reservations.Find(id);
     int customerId = (int)Session["customer"];
     Customer customer = db.Customers.Find(customerId);
     var checkedIn = CustomerOperations.CheckIn(ref customer, ref reservation, curr.time);
     if(checkedIn)
         db.SaveChanges();
     //TODO: else
     return RedirectToAction("Index");
 }
Example #25
0
        public ActionResult SavedFreelancers(int?idfromview)  //Hämtar sparade frilansare för en customer och skickar tillbaka en lista med dessa
        {
            if (idfromview == null)
            {
                idfromview = 5;
            }

            int?id = idfromview;  //Hårdkodad customer - inte länge Johan //Sara
            CustomerOperations co = new CustomerOperations();

            ViewBag.customer = co.GetCustomerById(id);

            return(View(co.GetSavedFreelancersList(id)));
        }
        public ActionResult ListCustomers(int draw, int start, int length, int managementid, int technicianid, int active)
        {
            using (var context = new DataContext())
            {
                try
                {
                    Account account             = base.GetLoginAccount();
                    IQueryable <Customer> query = CustomerOperations.TryList(account, context).Where(c => c.active == active);

                    // Handle filtering
                    if (managementid != Account.ACCOUNT_ANY)
                    {
                        query = query.Where(c => c.managementid == managementid);
                    }
                    if (technicianid != Account.ACCOUNT_ANY)
                    {
                        query = query.Where(c => c.technicianid == technicianid);
                    }

                    // Possibly apply filter
                    var searchstring = Request["search[value]"];
                    if (!String.IsNullOrWhiteSpace(searchstring))
                    {
                        query = query.Where(c =>
                                            c.name.Contains(searchstring) ||
                                            c.orgnumber.Contains(searchstring) ||
                                            c.address.Contains(searchstring));
                    }
                    int recordsFiltered = query.Count();

                    // Execute query
                    IList <Customer> dbms = query.OrderBy(c => c.name).Skip(start).Take(length).ToList();
                    int recordsTotal      = context.Customers.Count();

                    // Compose view models
                    IList <UICustomer_List> uims = new List <UICustomer_List>(dbms.Count);
                    foreach (Customer dbm in dbms)
                    {
                        uims.Add(new UICustomer_List(dbm));
                    }
                    return(Json(new { draw = draw, recordsTotal = recordsTotal, recordsFiltered = recordsFiltered, data = uims }));
                }
                catch (Exception e)
                {
                    base.HandleException("ListCustomers", e);
                    return(null);
                }
            }
        }
Example #27
0
        public void UpdateShouldChangeTheData()
        {
            var northwindEntities = new NorthwindEntities();
            var customerId        = "AAAAA";

            CustomerOperations.Insert(northwindEntities, customerId, "Test company");

            CustomerOperations.Update(northwindEntities, customerId, "Updated name");

            var customer = CustomerOperations.FindById(northwindEntities, customerId);

            CustomerOperations.Delete(northwindEntities, customerId);

            Assert.AreEqual(customer.CustomerID, customerId);
        }
        private void ExportByCountryButton_Click(object sender, EventArgs e)
        {
            var country = ((Countries)CountryComboBox.SelectedItem);

            if (country.CountryIdentifier == -1)
            {
                MessageBox.Show("Please select a country");
                return;
            }
            else
            {
                var excluded = CustomerOperations.ToFile(_customerItems, country.Name);
                MessageBox.Show(excluded.ToString());
            }
        }
        private async void CustomersTestForm_Shown(object sender, EventArgs e)
        {
            try
            {
                CountryComboBox.DataSource = await CountryOperations.CountriesWithSelectAsync();

                _customerItems = await CustomerOperations.GetCustomersAsync();

                ExportByCountryButton.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load data\n{ex.Message}");
            }
        }
        public static async Task Main()
        {
            try
            {
                var operations = new CustomerOperations();
                var discount   = await operations.AverageDiscount();

                Logger.Log($"Discount: {discount}");
            }
            catch (DivideByZeroException)
            {
                Console.WriteLine("Caught a divide by zero");
            }

            Console.ReadLine();
        }