/// <summary> /// Metoda wykonywana po kliknięciu przycisku "Doda przedmiot" /// która dodaje nam produkt do bazy danych i wyświetla informację o że przedmiot się dodał /// po czym zamyka okno /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Add_Click(object sender, RoutedEventArgs e) { var product = new Product { CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow, RecId = Guid.NewGuid(), Name = Name.Text, Description = Description.Text, Id = Id.Text, Brand = Brand.Text, Model = Model.Text, Owner = Owner.Text, Type = (ProductType)TypeComboBox.SelectedItem }; using (var context = new InventoryManagerContext()) { context.Products.Add(product); context.SaveChanges(); MessageBox.Show("Pomyślnie dodano produkt!", "Dodawanie produktu", MessageBoxButton.OK, MessageBoxImage.Information); } Close(); }
/// <summary> /// A Lambda function to respond to HTTP Get methods from API Gateway /// </summary> /// <param name="request"></param> /// <returns>The API Gateway response.</returns> public APIGatewayProxyResponse GetPallet(APIGatewayProxyRequest request) { if (request.PathParameters != null && request.PathParameters.ContainsKey("palletid") && int.TryParse(request.PathParameters["palletid"], out var palletid)) { InventoryManagerContext con = new InventoryManagerContext(); palletservice palletser = new palletservice(con); GetPalletResponse res = palletser.getpalletResponse(palletid); return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK, Body = JsonConvert.SerializeObject(res) }); } // InventoryManagerContext inventoryManager = var response = new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.NotFound }; return(response); }
/// <summary> /// Metoda pobierająca nam wszystkie produkty z bazy danych /// </summary> /// <returns></returns> private List <Product> GetProducts() { var products = new List <Product>(); using (var context = new InventoryManagerContext()) { products = context.Products.ToList(); } ProductsDataGrid.ItemsSource = products; return(products); }
private InventoryItemsController GetTestController() { InventoryItemsController controller; var options = new DbContextOptionsBuilder <InventoryManagerContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new InventoryManagerContext(options)) { context.InventoryItem.Add(new InventoryItem()); context.SaveChanges(); controller = new InventoryItemsController(context); } return(controller); }
/// <summary> /// Metoda która usuwa nam wybrany na gridzie produkt z bazy danych /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteProductClick(object sender, RoutedEventArgs e) { var selectedProduct = (Product)ProductsDataGrid.SelectedItem; if (selectedProduct == null) { return; } using (var context = new InventoryManagerContext()) { var product = context.Products.FirstOrDefault <Product>(x => x.RecId == selectedProduct.RecId); context.Remove(product); context.SaveChanges(); MessageBox.Show("Pomyślnie usunięto produkt!", "Usuwanie produktu", MessageBoxButton.OK, MessageBoxImage.Information); } }
public APIGatewayProxyResponse GetPallet(APIGatewayProxyRequest request) { if (request.PathParameters != null && request.PathParameters.ContainsKey("palletId") && int.TryParse(request.PathParameters["palletId"], out var palletId)) { // get Pallet through service var inventoryManagerContext = new InventoryManagerContext(); var palletService = new PalletService(inventoryManagerContext); var getPalletResponce = palletService.GetPallet(palletId); return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK, Body = JsonConvert.SerializeObject(getPalletResponce) }); } return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.NotFound }); }
public PalletService(InventoryManagerContext inventoryManagerContext) { _inventoryManagerContext = inventoryManagerContext; }
public ValuesController(InventoryManagerContext context) { _context = context; }
public InventoryItemsController(InventoryManagerContext context) { _context = context; }
public palletservice(InventoryManagerContext context) { managercontext = context; }
public PalletService() { _inventorManagerContext = new InventoryManagerContext(); }