public async Task <TableTabVM> UpdateTableAsync(CreateTableVM table) { var item = await _db.Tables.GetByIdAsync(table.Id); item.Number = table.Number; item.Info = table.Info; item.LocationId = table.LocationId; var newItem = await _db.Tables.UpdateAsync(item); return(new TableTabVM(newItem)); }
public async Task <TableTabVM> CreateTableAsync(CreateTableVM table) { var dbTable = new Table { Info = table.Info, LocationId = table.LocationId, Number = table.Number }; var tableNew = await _db.Tables.CreateAsync(dbTable); var ret = new TableTabVM(tableNew); return(ret); }
public async Task <IActionResult> UpdateTable([FromForm] CreateTableVM table) { try { if (table == null) { throw new Exception("Menu object is missing"); } var tablePage = await _tableService.UpdateTableAsync(table); return(Ok(tablePage)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }