private bool ValidateUpdateTableNumberRequest(DomainTable table, JsonPatchDocument <DomainTable> patchDoc) { var tableNumberPath = DomainTable.PropNameToPatchPath[nameof(DomainTable.Number)]; var tableNumberRequest = patchDoc.Operations.SingleOrDefault(o => o.path.Equals(tableNumberPath)); var isTableNumberRequest = tableNumberRequest != null; if (!isTableNumberRequest) { return(false); } var requestedTableNumber = Convert.ToInt32(tableNumberRequest.value); if (requestedTableNumber <= 0) { throw new InvalidRequestException("Table number cannot be 0 or a negative number."); } if (requestedTableNumber == table.Number) { patchDoc.Operations.Remove(tableNumberRequest); return(false); } _tableService.ValidateTableNumberUnique(requestedTableNumber); return(true); }
public Table(DomainTable domainTable) { Id = domainTable.Id; Number = domainTable.Number; PartySize = domainTable.PartySize; IsAvailable = domainTable.IsAvailable; }
private static bool ValidateUpdateTableSizeRequest(DomainTable table, JsonPatchDocument <DomainTable> patchDoc) { var tableSizePath = DomainTable.PropNameToPatchPath[nameof(DomainTable.PartySize)]; var tableSizeRequest = patchDoc.Operations.SingleOrDefault(o => o.path.Equals(tableSizePath)); var isTableSizeRequest = tableSizeRequest != null; if (!isTableSizeRequest) { return(false); } var requestedTableSize = Convert.ToInt32(tableSizeRequest.value); if (requestedTableSize <= 0) { throw new InvalidRequestException("Table's supported PartySize must be bigger than 0."); } if (requestedTableSize == table.PartySize) { patchDoc.Operations.Remove(tableSizeRequest); return(false); } return(true); }