public async Task <IActionResult> PutSlot(int slotId, SlotCreateViewModel model) { if (slotId == 0) { return(null); } var sLot = _context.slots.FirstOrDefault(p => p.SlotId == slotId); if (sLot == null) { return(NotFound()); } sLot.No = model.SlotNo; _context.Update(sLot); if (_context.SaveChanges() == 0) { return(BadRequest()); } return(Ok()); }
public async Task <ActionResult <Slot> > PostSlot(SlotCreateViewModel model) { if (model == null) { } var userId = _caller.Claims.Single(c => c.Type == "id"); var OnlineUser = await _userManager.FindByIdAsync(userId.Value); var slot = new Slot() { No = model.SlotNo, Parking = _context.parkings .FirstOrDefault(p => p.appUser.Id == OnlineUser.Id), Reserved = false }; _context.slots.Add(slot); await _context.SaveChangesAsync(); return(Ok()); }