mirror of
https://github.com/yummy4friends/y4f.git
synced 2024-12-27 07:38:21 +01:00
Add vorbestllungsdata into Table BestellungspositionHasMenuitem
This commit is contained in:
parent
32bedc209c
commit
9add5ac628
@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebApi.Data;
|
||||
using WebApi.Models;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class BestellungspositionHasMenuitemsController : ControllerBase
|
||||
{
|
||||
private readonly WebApiContext _context;
|
||||
|
||||
public BestellungspositionHasMenuitemsController(WebApiContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/BestellungspositionHasMenuitems
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<BestellungspositionHasMenuitem>>> GetBestellungspositionHasMenuitem()
|
||||
{
|
||||
if (_context.BestellungspositionHasMenuitem == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return await _context.BestellungspositionHasMenuitem.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/BestellungspositionHasMenuitems/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<BestellungspositionHasMenuitem>> GetBestellungspositionHasMenuitem(int? id)
|
||||
{
|
||||
if (_context.BestellungspositionHasMenuitem == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
var bestellungspositionHasMenuitem = await _context.BestellungspositionHasMenuitem.FindAsync(id);
|
||||
|
||||
if (bestellungspositionHasMenuitem == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return bestellungspositionHasMenuitem;
|
||||
}
|
||||
|
||||
// PUT: api/BestellungspositionHasMenuitems/5
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutBestellungspositionHasMenuitem(int? id, BestellungspositionHasMenuitem bestellungspositionHasMenuitem)
|
||||
{
|
||||
if (id != bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(bestellungspositionHasMenuitem).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!BestellungspositionHasMenuitemExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/BestellungspositionHasMenuitems
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<BestellungspositionHasMenuitem>> PostBestellungspositionHasMenuitem(BestellungspositionHasMenuitem bestellungspositionHasMenuitem)
|
||||
{
|
||||
if (_context.BestellungspositionHasMenuitem == null)
|
||||
{
|
||||
return Problem("Entity set 'WebApiContext.BestellungspositionHasMenuitem' is null.");
|
||||
}
|
||||
_context.BestellungspositionHasMenuitem.Add(bestellungspositionHasMenuitem);
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
if (BestellungspositionHasMenuitemExists(bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung))
|
||||
{
|
||||
return Conflict();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return CreatedAtAction("GetBestellungspositionHasMenuitem", new { id = bestellungspositionHasMenuitem.Bestellungsposition_IDBestellung }, bestellungspositionHasMenuitem);
|
||||
}
|
||||
|
||||
// DELETE: api/BestellungspositionHasMenuitems/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteBestellungspositionHasMenuitem(int? id)
|
||||
{
|
||||
if (_context.BestellungspositionHasMenuitem == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
var bestellungspositionHasMenuitem = await _context.BestellungspositionHasMenuitem.FindAsync(id);
|
||||
if (bestellungspositionHasMenuitem == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.BestellungspositionHasMenuitem.Remove(bestellungspositionHasMenuitem);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
private bool BestellungspositionHasMenuitemExists(int? id)
|
||||
{
|
||||
return (_context.BestellungspositionHasMenuitem?.Any(e => e.Bestellungsposition_IDBestellung == id)).GetValueOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public partial class WebApiContext : DbContext
|
||||
|
||||
public virtual DbSet<Admin> Admins { get; set; }
|
||||
|
||||
//public virtual DbSet<BestellungspositionHasMenuitem> BestellungspositionHasMenuitem { get; set; }
|
||||
public virtual DbSet<BestellungspositionHasMenuitem> BestellungspositionHasMenuitem { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -83,31 +83,31 @@ public partial class WebApiContext : DbContext
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("fk_Bestellungsposition_Rabatt1");
|
||||
|
||||
entity.HasMany(d => d.MenuItemIdmenuItems).WithMany(p => p.BestellungspositionIdbestellungs)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"BestellungspositionHasMenuitem",
|
||||
r => r.HasOne<Menuitem>().WithMany()
|
||||
.HasForeignKey("MenuItemIdmenuItem")
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("fk_Bestellungsposition_has_MenuItem_MenuItem1"),
|
||||
l => l.HasOne<Bestellungsposition>().WithMany()
|
||||
.HasForeignKey("BestellungspositionIdbestellung")
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("fk_Bestellungsposition_has_MenuItem_Bestellungsposition1"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("BestellungspositionIdbestellung", "MenuItemIdmenuItem")
|
||||
.HasName("PRIMARY")
|
||||
.HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
|
||||
j.ToTable("bestellungsposition_has_menuitem");
|
||||
j.HasIndex(new[] { "MenuItemIdmenuItem" }, "fk_Bestellungsposition_has_MenuItem_MenuItem1");
|
||||
j.IndexerProperty<int>("BestellungspositionIdbestellung")
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("Bestellungsposition_IDBestellung");
|
||||
j.IndexerProperty<int>("MenuItemIdmenuItem")
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("MenuItem_IDMenuItem");
|
||||
});
|
||||
//entity.HasMany(d => d.MenuItemIdmenuItems).WithMany(p => p.BestellungspositionIdbestellungs)
|
||||
// .UsingEntity<Dictionary<string, object>>(
|
||||
// "BestellungspositionHasMenuitem",
|
||||
// r => r.HasOne<Menuitem>().WithMany()
|
||||
// .HasForeignKey("MenuItemIdmenuItem")
|
||||
// .OnDelete(DeleteBehavior.ClientSetNull)
|
||||
// .HasConstraintName("fk_Bestellungsposition_has_MenuItem_MenuItem1"),
|
||||
// l => l.HasOne<Bestellungsposition>().WithMany()
|
||||
// .HasForeignKey("BestellungspositionIdbestellung")
|
||||
// .OnDelete(DeleteBehavior.ClientSetNull)
|
||||
// .HasConstraintName("fk_Bestellungsposition_has_MenuItem_Bestellungsposition1"),
|
||||
// j =>
|
||||
// {
|
||||
// j.HasKey("BestellungspositionIdbestellung", "MenuItemIdmenuItem")
|
||||
// .HasName("PRIMARY")
|
||||
// .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
|
||||
// j.ToTable("bestellungsposition_has_menuitem");
|
||||
// j.HasIndex(new[] { "MenuItemIdmenuItem" }, "fk_Bestellungsposition_has_MenuItem_MenuItem1");
|
||||
// j.IndexerProperty<int>("BestellungspositionIdbestellung")
|
||||
// .HasColumnType("int(11)")
|
||||
// .HasColumnName("Bestellungsposition_IDBestellung");
|
||||
// j.IndexerProperty<int>("MenuItemIdmenuItem")
|
||||
// .HasColumnType("int(11)")
|
||||
// .HasColumnName("MenuItem_IDMenuItem");
|
||||
// });
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Kunde>(entity =>
|
||||
@ -214,16 +214,16 @@ public partial class WebApiContext : DbContext
|
||||
entity.Property(e => e.Password).HasMaxLength(100);
|
||||
});
|
||||
|
||||
//modelBuilder.Entity<BestellungspositionHasMenuitem>(entity =>
|
||||
//{
|
||||
// entity.HasKey(e => new { e.Bestellungsposition_IDBestellung, e. })
|
||||
// .HasName("PRIMARY");
|
||||
modelBuilder.Entity<BestellungspositionHasMenuitem>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Bestellungsposition_IDBestellung, e.MenuItem_IDMenuItem })
|
||||
.HasName("PRIMARY");
|
||||
|
||||
// entity.ToTable("bestellungsposition_has_menuitem");
|
||||
entity.ToTable("bestellungsposition_has_menuitem");
|
||||
|
||||
// entity.Property(e => e.BestellungspositionId).HasColumnType("int(11)");
|
||||
// entity.Property(e => e.MenuitemId).HasColumnType("int(11)");
|
||||
//});
|
||||
entity.Property(e => e.Bestellungsposition_IDBestellung).HasColumnType("int(11)").HasColumnName("Bestellungsposition_IDBestellung");
|
||||
entity.Property(e => e.MenuItem_IDMenuItem).HasColumnType("int(11)").HasColumnName("MenuItem_IDMenuItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<MenuitemHasAllergie>(entity =>
|
||||
{
|
||||
|
@ -121,12 +121,12 @@
|
||||
|
||||
Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionen", bestellungsposition);
|
||||
|
||||
// //Add menuitems to bestellungspositionHasMenuItem
|
||||
//BestellungspositionHasMenuitem bestellungspositionHasMenuItem = new BestellungspositionHasMenuitem();
|
||||
//bestellungspositionHasMenuItem.Bestellungsposition_IDBestellung = bestellungsposition.Idbestellung;
|
||||
//bestellungspositionHasMenuItem.MenuItem_IDMenuItem = item.Key;
|
||||
//Add menuitems to bestellungspositionHasMenuItem
|
||||
BestellungspositionHasMenuitem bestellungspositionHasMenuItem = new BestellungspositionHasMenuitem();
|
||||
bestellungspositionHasMenuItem.Bestellungsposition_IDBestellung = bestellungsposition.Idbestellung;
|
||||
bestellungspositionHasMenuItem.MenuItem_IDMenuItem = item.Key;
|
||||
|
||||
//Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionhasmenuitems", bestellungspositionHasMenuItem);
|
||||
Http.PostAsJsonAsync("https://localhost:7076/api/bestellungspositionhasmenuitems", bestellungspositionHasMenuItem);
|
||||
}
|
||||
|
||||
// delete all localStorage
|
||||
@ -157,7 +157,7 @@
|
||||
menuitemkategories = await Http.GetFromJsonAsync<List<Menuitemkategorie>>("https://localhost:7076/api/Menuitemkategories");
|
||||
menuitemueberkategories = await Http.GetFromJsonAsync<List<Menuitemueberkategorie>>("https://localhost:7076/api/Menuitemueberkategories");
|
||||
rabatte = await Http.GetFromJsonAsync<List<Rabatt>>("https://localhost:7076/api/Rabatte");
|
||||
//bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems");
|
||||
bestellungspositionHasMenuitems = await Http.GetFromJsonAsync<List<BestellungspositionHasMenuitem>>("https://localhost:7076/api/BestellungspositionHasMenuitems");
|
||||
|
||||
// test use the first kunde
|
||||
kunde = kunden[0];
|
||||
|
Loading…
Reference in New Issue
Block a user