Ejemplo n.º 1
0
        public void Edit(Guid clientID)
        {
            var client = _context.Clients.Where(c => c.ID == clientID).FirstOrDefault();
            Dictionary <string, string> data = ClientInput();

            client.Name        = data["name"];
            client.BussinessID = data["busID"];
            client.VAT_ID      = data["vat"];
            client.Phone       = data["phone"];
            client.Email       = data["email"];
            AdressService      adressService      = new AdressService(_context);
            ClientGroupService clientGroupService = new ClientGroupService(_context);

            Console.WriteLine("Input Address");
            client.AdressID = adressService.Create();
            Console.WriteLine("Input Delivery Address");
            client.DeliveryAdressID = adressService.Create();
            Console.WriteLine("Please select Pricelist code");
            client.PricelistCode = (PricelistCode)Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please input Client Group Name");
            string groupName = Console.ReadLine();

            client.ClientsGroupID = clientGroupService.ReadByName(groupName);
            Console.WriteLine("Please input credit limits");
            client.CreditLimit = (double)Convert.ToInt32(Console.ReadLine());
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void ReadByName(string name)
        {
            AdressService      adressService      = new AdressService(_context);
            ClientGroupService clientGroupService = new ClientGroupService(_context);
            var client = _context.Clients.Where(c => c.Name == name)
                         .Include(c => c.Group)
                         .Include(c => c.Branches)
                         .Include(c => c.ClientsOrders).FirstOrDefault();

            ClientOutput(client);
            Console.WriteLine("Client Address");
            adressService.Read(client.AdressID);
            Console.WriteLine("Client Delivery Address");
            adressService.Read(client.DeliveryAdressID);
            Console.WriteLine("Clients Pricelist code");
            Console.WriteLine(client.PricelistCode);
            Console.WriteLine("Client Group");
            Console.WriteLine(client.Group.Name);
            Console.WriteLine("Credit limit");
            Console.WriteLine(client.CreditLimit);
            Console.WriteLine("Clients orders:");
            foreach (var item in client.ClientsOrders)
            {
                Console.WriteLine(item.OrderNumber);
            }
            Console.WriteLine("Clients branches:");
            foreach (var item in client.Branches)
            {
                Console.WriteLine(item.BranchName);
            }
        }
Ejemplo n.º 3
0
        public void Read(Guid?clientID)
        {
            AdressService      adressService      = new AdressService(_context);
            ClientGroupService clientGroupService = new ClientGroupService(_context);
            var client = _context.Clients.Where(c => c.ID == clientID).Include(c => c.Group).FirstOrDefault();

            ClientOutput(client);
            Console.WriteLine("Client Address");
            adressService.Read(client.AdressID);
            Console.WriteLine("Client Delivery Address");
            adressService.Read(client.DeliveryAdressID);
            Console.WriteLine("Clients Pricelist code");
            Console.WriteLine(client.PricelistCode);
            Console.WriteLine("Client Group");
            Console.WriteLine(client.Group.Name);
        }