public ApplicationViewModel()
        {
            service    = new ServiceModule("mvvmApp.Dal.Abstract.Entities.ApplicationContext");
            serviceAdo = new ServiceModuleAdo();

            List <Item> computersIEnum = serviceAdo.Items.GetAllItems().ToList();//service.Items.GetAllItems().ToList();//client.GetAllItems().ToList(); //


            try
            {
                clientDto = new ItemDTOServiceClient();

                List <ItemDTO> itemDTOs = new List <ItemDTO>(clientDto.GetAll());

                var mapperConfig = new MapperConfiguration(config => config.CreateMap <ItemDTO, ItemModel>());
                var map          = mapperConfig.CreateMapper();

                Computers = new ObservableCollection <ItemModel>
                                (map.Map <List <ItemDTO>, ObservableCollection <ItemModel> >(itemDTOs));
            }
            catch (Exception ex)
            {
            }

            try
            {
                client = new ItemServiceClient();
                if (client != null)
                {
                    string ItemData = "";
                    foreach (var item in computersIEnum)
                    {
                        ItemData += item.ToString() + "\n";
                    }
                    client.ItemsFromDatabase(ItemData);
                }
            }
            catch (Exception ex)
            {
            }



            //var mapperConf  = new MapperConfiguration(conf => conf.CreateMap<Item, ItemModel>());
            //var mapper = mapperConf.CreateMapper();

            //Computers = new ObservableCollection<ItemModel>
            //    (mapper.Map<List<Item>, ObservableCollection<ItemModel>>(computersIEnum));



            //serviceAdo = new ServiceModuleAdo();

            //var computersIEnum = serviceAdo.Items.GetAllItems().ToList();

            //var orders = serviceAdo.Orders.GetAllItems();

            //Computers = serviceAdo.Computers;
        }
Ejemplo n.º 2
0
        // ServiceModule service;

        public OrderViewModel(ObservableCollection <ItemModel> items)
        {
            serviceAdo = new ServiceModuleAdo();
            orderRepo  = new OrderRepository <Order>(new ApplicationContext("mvvmApp.Dal.Abstract.Entities.ApplicationContext"));
            //var orderedComputers = orderRepository.GetOrderedItems(serviceAdo.Orders.GetItem(1002).Id).ToList();

            OrderedComputers = new ObservableCollection <ItemModel>();
            orderedComputers = items;
        }
Ejemplo n.º 3
0
        public UpdateViewModel(ItemModel updatedComputer)
        {
            service    = new ServiceModule("mvvmApp.Dal.Abstract.Entities.ApplicationContext");
            serviceAdo = new ServiceModuleAdo();
            computer   = updatedComputer;

            image   = computer.ImagePath;
            company = computer.Company;
            title   = computer.Title;
            price   = computer.Price;
            id      = computer.Id;
        }
Ejemplo n.º 4
0
 public AddViewModel()
 {
     serviceAdo = new ServiceModuleAdo();
     computer   = new ItemModel();
 }