private async void Order_DataGrid_Loaded(object sender, RoutedEventArgs e)
        {
            //I Do this Becuase OrderDetail.Produce Is Null But OrderDetail.ProduceID Has Value
            //Even OrderDetail.Order and OrderDetail.OrderID has Value
            //TODO:Bug

            if (_isUpdate)
            {
                _newOrder = await _orderManager.FindByIdAsync(_newOrder.ID).ConfigureAwait(false);

                _ordernumber = _newOrder.Number;
                CreateDate_DatePicker.SelectedDate = _newOrder.Date;
                PersonalName_ComboBox.SelectedItem = PersonalName_ComboBox.ItemsSource
                                                     .Cast <string>().Single(x => x.Equals(_newOrder.Personal.Name));

                var temp = _orderDetailManager.Entity.Where(x => x.OrderID.Equals(_newOrder.ID)).ToList();////////
                foreach (var item in temp)
                {
                    item.Produce = await _produceManager.FindByIdAsync(item.ProduceID);

                    _orderDetailDtoList.Add(_mapper.Map <OrderDetailDto>(item));
                }
                Order_DataGrid.ItemsSource = _orderDetailDtoList.ToList();
            }
        }
예제 #2
0
        private async Task DeleteOrder(OrderDto orderDto)
        {
            var order = await _orderManager.FindByIdAsync(orderDto.OrderID).ConfigureAwait(false);

            await _orderManager.DeleteAsync(order).ConfigureAwait(false);

            _orderDtoList.Remove(orderDto);
        }
        private async void DeleteOrderDetailAsync(OrderDetailDto orderDetailDto)
        {
            if (Order_DataGrid.SelectedIndex < -1)
            {
                //Check Item Exist in Database
                OrderDetail result = _createdOrderDetails.FirstOrDefault(x => x.ID.Equals(orderDetailDto.ID));
                if (result == null)
                {
                    result = await _orderDetailManager.FindByIdAsync(orderDetailDto.ID).ConfigureAwait(false);

                    _deleteOrderDetails.Add(result);
                }
                else
                {
                    _createdOrderDetails.Remove(result);
                }
                _ordernumber--;
            }
        }