public async Task <IActionResult> DeleteOrder([FromRoute] int clientId, [FromRoute] int orderId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var order = await _context.CurrentOrders.FindAsync(orderId); if (order == null) { return(NotFound()); } if (order.ClientId != clientId) { return(BadRequest()); } ArchivedOrder archivedOrder = new ArchivedOrder(order); _context.ArchivedOrders.Add(archivedOrder); _context.CurrentOrders.Remove(order); await _context.SaveChangesAsync(); return(Ok(order)); }
public ArchivedOrderViewModel(ArchivedOrder archivedOrder) { this.archivedOrder = archivedOrder; IsUpdateOrderItemList = true; Service s = new Service(); AllOrderItemList = s.GetOrderItemEmployeeArchive(); //Grouping a list by orderID archivedOrder.lvOrder.ItemsSource = AllOrderItemList; if (AllOrderItemList != null) { if (AllOrderItemList.Count > 0) { archivedOrder.lvOrder.Visibility = Visibility.Visible; archivedOrder.msgNoOrder.Visibility = Visibility.Collapsed; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(archivedOrder.lvOrder.ItemsSource); PropertyGroupDescription groupDescription = new PropertyGroupDescription("Header"); view.GroupDescriptions.Add(groupDescription); } else { archivedOrder.lvOrder.Visibility = Visibility.Collapsed; archivedOrder.msgNoOrder.Visibility = Visibility.Visible; } } else { archivedOrder.lvOrder.Visibility = Visibility.Collapsed; archivedOrder.msgNoOrder.Visibility = Visibility.Visible; } }
private void Napustii_Click(object sender, RoutedEventArgs e) { ArchivedOrder archivedOrder = new ArchivedOrder(); StackPanelMain.Children.Clear(); StackPanelMain.Children.Add((UserControl)archivedOrder); }
/// <summary> /// Method to change the menu /// </summary> /// <param name="sender">Selected UserControl</param> public void SwitchScreen(object sender) { welcomeMsg.Visibility = Visibility.Collapsed; DataGridAllMenu.Visibility = Visibility.Collapsed; processOrdering.Visibility = Visibility.Collapsed; acceptReject.Visibility = Visibility.Collapsed; var screen = ((UserControl)sender); if (screen != null) { StackPanelMain.Children.Clear(); StackPanelMain.Children.Add(screen); //ArchivedOrder ao = StackPanelMain.FindName("ArchivedOrder") as ArchivedOrder; //ArchivedOrder ar = new ArchivedOrder(); if (screen.Name == "ArchivedOrder") { ArchivedOrder archivedOrder = new ArchivedOrder(); StackPanelMain.Children.Clear(); StackPanelMain.Children.Add(archivedOrder); } else { StackPanelMain.Children.Clear(); StackPanelMain.Children.Add(screen); } } }
public void RestoreMemento_MementoValueUsed_PreviousStateRestored() { Order o = new Order(); ArchivedOrder ao = new ArchivedOrder(); o.Name = "ABC"; o.Phone = "123456789"; o.Address = "DEF 123"; o.Amount = 10; ao.Memento = o.SaveMemento(); o.Name = "XYZ"; o.RestoreMemento(ao.Memento); Assert.AreEqual(o.Name, "ABC"); }
public void SaveMemento_OriginalChanged_MementoStateNotChanged() { Order o = new Order(); Order o2 = new Order(); ArchivedOrder ao = new ArchivedOrder(); o.Name = "ABC"; o.Phone = "123456789"; o.Address = "DEF 123"; o.Amount = 10; ao.Memento = o.SaveMemento(); o.Name = "XYZ"; o2.RestoreMemento(ao.Memento); Assert.IsTrue(o.Name.Equals("XYZ") && o2.Name.Equals("ABC")); }
public void SaveMemento_MementoCreated_MementoSameAsOriginal() { Order o = new Order(); Order o2 = new Order(); ArchivedOrder ao = new ArchivedOrder(); o.Name = "ABC"; o.Phone = "123456789"; o.Address = "DEF 123"; o.Amount = 10; ao.Memento = o.SaveMemento(); o2.RestoreMemento(ao.Memento); Assert.IsTrue(o.Name.Equals(o2.Name) && o.Phone.Equals(o2.Phone) && o.Address.Equals(o2.Address) && o.Amount == o2.Amount); }