public async Task <IActionResult> PostPlateTimeRestaurantGoer([FromBody] PlateTimeRestaurantGoer plateTimeRestaurantGoer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PlateTimeRestaurantGoer.Add(plateTimeRestaurantGoer); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPlateTimeRestaurantGoer", new { id = plateTimeRestaurantGoer.Id }, plateTimeRestaurantGoer)); }
public void JoinPlateTime(int plateTimeId, int resGoerId) { PlateTimeRestaurantGoer ptrg = new PlateTimeRestaurantGoer(); ptrg.PlateTimeId = plateTimeId; ptrg.RestaurantGoerId = resGoerId; var exists = GetEntry(plateTimeId, resGoerId); if (exists != null) { return; } db.Add(ptrg); db.SaveChanges(); }
public async Task <IActionResult> PutPlateTimeRestaurantGoer([FromRoute] int id, [FromBody] PlateTimeRestaurantGoer plateTimeRestaurantGoer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != plateTimeRestaurantGoer.Id) { return(BadRequest()); } _context.Entry(plateTimeRestaurantGoer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlateTimeRestaurantGoerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }