Esempio n. 1
0
        public IActionResult AvailableItems(int enemy)
        {
            //ToDo
            IEnumerable <Item> itemslist;

            if (_enemyServices.GetById(enemy).EnemyItems == null)
            {
                itemslist = _itemServices.GetAll();
            }
            else
            {
                //var enemy_items = _enemyServices.GetById(enemy).EnemyItems.Select(i => i.ItemId);
                //var excluding_items = _itemServices.GetAll().Where(i => !enemy_items.Contains(i.Id));
                //var not_in_enemy = excluding_items.Select(i => i.Id);

                itemslist = _itemServices
                            .GetAll()
                            .Where(i => !_enemyServices
                                   .GetById(enemy)
                                   .EnemyItems.Select(e => e.ItemId).Contains(i.Id));
            }

            EnemyItemsViewModel model = new EnemyItemsViewModel
            {
                EnemyId = enemy,
                Items   = itemslist
            };

            return(View(model));
        }
        private void PopulateComboboxBarang()
        {
            _itemRepo = new ItemServices();
            var Data = AutoMapper.Mapper.Map <List <MasterItemDto> >(_itemRepo.GetAll().Where(x => x.STATUS == Status.Aktif));

            _dataBarang = CollectionViewSource.GetDefaultView(Data);

            _dataBarang.Filter = new Predicate <object>(FilterCandidates);

            var TransportCompositeCollection = new CompositeCollection();

            TransportCompositeCollection.Add(new ComboBoxItem()
            {
                Content = "Please Select"
            });
            TransportCompositeCollection.Add(new CollectionContainer()
            {
                Collection = _dataBarang
            });

            NamaBarang.ItemsSource = TransportCompositeCollection;

            filters.Clear();
            if (_dataBarang != null)
            {
                AddFilterAndRefresh("JENIS_BARANG", candidate => (JenisBarang.SelectedItem.GetType() == typeof(ItemType) && candidate.JENIS_BARANG == (ItemType)JenisBarang.SelectedItem));
            }
            //NamaBarang.SelectedValuePath = "ID";
            //NamaBarang.DisplayMemberPath = "NAMA_BARANG";
            NamaBarang.SelectedIndex = 0;
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            ItemsViewModel itemsView = new ItemsViewModel();

            itemsView.Items = _itemServices.GetAll();

            return(View(itemsView));
        }
Esempio n. 4
0
        private void Btn_Simpan_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _itemServices = new ItemServices();

                if (JenisBarang.SelectedItem.GetType() != typeof(ItemType))
                {
                    MessageBox.Show("Jenis Barang harus dipilih", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                if (string.IsNullOrEmpty(NamaBarang.Text))
                {
                    MessageBox.Show("Nama Barang tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                if (string.IsNullOrEmpty(HargaBarang.Text))
                {
                    MessageBox.Show("Harga Barang tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                if (string.IsNullOrEmpty(OngkosKontainer.Text))
                {
                    MessageBox.Show("Ongkos Kontainer tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                var Dto = new MasterItemDto();
                Dto.NAMA_BARANG      = NamaBarang.Text;
                Dto.HARGA            = decimal.Parse(HargaBarang.Text);
                Dto.JENIS_BARANG     = (ItemType)JenisBarang.SelectedItem;
                Dto.ONGKOS_CONTAINER = decimal.Parse(OngkosKontainer.Text);
                Dto.STATUS           = Core.Status.Aktif;
                Dto.ID = int.Parse(IdBarang.Text);

                var DataExisting = _itemServices.GetAll().Where(x => !string.IsNullOrEmpty(x.NAMA_BARANG) &&
                                                                x.NAMA_BARANG.ToUpper() == Dto.NAMA_BARANG.ToUpper() && x.JENIS_BARANG == Dto.JENIS_BARANG).FirstOrDefault();

                if (DataExisting != null && DataExisting.ID != Dto.ID)
                {
                    MessageBox.Show("Barang sudah ada di database", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                _itemServices.Save(Dto);
                MessageBox.Show("Update Data Sukses", "Sukses", MessageBoxButton.OK, MessageBoxImage.Information);
                CloseWin();
            }
            catch (Exception exp)
            {
                MessageBox.Show("Update Data Error", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void PopulateData()
        {
            var Data = AutoMapper.Mapper.Map <List <MasterItemDto> >(_itemServices.GetAll());

            _data = CollectionViewSource.GetDefaultView(Data);

            _data.GroupDescriptions.Clear();
            var GroupDescription = new PropertyGroupDescription();

            GroupDescription.Converter    = new EnumDescriptionConverter();
            GroupDescription.PropertyName = "JENIS_BARANG";
            _data.GroupDescriptions.Add(GroupDescription);

            _data.Filter = new Predicate <object>(FilterCandidates);

            Dgv_Home.ItemsSource = _data;
        }