public ActionResult <MenuItemReadDto> UpdateTable(int id, [FromBody] MenuItemUpdateDto tableUpdateDto) { var tableModelFromRepo = _tableRepo.GetElementById(id); if (tableModelFromRepo == null) { return(NotFound()); } _mapper.Map(tableUpdateDto, tableModelFromRepo); _tableRepo.UpdateTable(tableModelFromRepo); _tableRepo.SaveChanges(); return(NoContent()); }
private void Save() { try { if (IsNewTable == false) { Data.Table table = _tablesRepository.GetTableById(ManipulatedTable.Id); table.Name = ManipulatedTable.Name; table.Capacity = ManipulatedTable.Capacity; _tablesRepository.UpdateTable(table); CancelRequested?.Invoke(); MessageHandler.InvokeSuccessMessage(Resources.InformationUpdateTable, Resources.InformationTableUpdated); } else { _tablesRepository.AddTable(new Table { Capacity = ManipulatedTable.Capacity, Name = ManipulatedTable.Name, IsOccupied = ManipulatedTable.IsOccupied, Id = ManipulatedTable.Id }); ToTableViewRequested?.Invoke(); MessageHandler.InvokeSuccessMessage(Resources.InformationAddTable, Resources.InformationTableAdded); } } catch (Exception e) { ErrorHandler.ThrowError(0, e.Message); } }
public void StartOccupancy(Data.Occupancy occupancy) { Data.Occupancy NewOccupancy = new Data.Occupancy(); if (SelectedReservation != null) { NewOccupancy.Reservation = SelectedReservation; } NewOccupancy.StartTime = DateTime.Now; NewOccupancy.Table = Table; NewOccupancy.Sales = new ObservableCollection <Data.Sale>(); CurrentOccupancy = _occupanciesRepository.AddOccupancy(NewOccupancy); Table.IsOccupied = true; _tablesRepository.UpdateTable(Table); UnpaidAmount = 0; PaidAmount = 0; TotalAmount = 0; }