Skip to content

Commit b698fdc

Browse files
committed
not working endpoints repaired
1 parent 6fb8184 commit b698fdc

File tree

15 files changed

+69
-29
lines changed

15 files changed

+69
-29
lines changed

TableBookingAPI/TableBooking.Logic/Converters/TableConverters/TableToGetConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public GetTablesDto TableToTableDto(Table table)
2121
{
2222
Id = table.Id,
2323
RestaurantId = table.RestaurantId,
24-
NumberOfSeats = table.NumberOfSeats
24+
NumberOfSeats = table.NumberOfSeats,
25+
Bookings = table.Bookings
2526
};
2627
}
2728
}

TableBookingAPI/TableBooking.Logic/Repositories/TableRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public TableRepository(TableBookingContext context) : base(context)
1313
public async Task<IEnumerable<Table>> GetTablesByRestaurantIdAsync(Guid restaurantId)
1414
{
1515
return await _objectSet
16-
.Include(x => x.RestaurantId)
16+
.Include(x => x.Restaurant)
1717
.Where(x => x.RestaurantId.Equals(restaurantId))
1818
.ToListAsync();
1919
}

TableBookingAPI/TableBooking.Model/Dtos/RestaurantDtos/RestaurantShortInfoDto.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class RestaurantShortInfoDto
77
public string Name { get; set; }
88
public string Type { get; set; }
99
public string Description { get; set; }
10+
public string Phone { get; set; }
1011
public string Location { get; set; }
1112
public string ImageURL { get; set; }
1213
public int Rating { get; set; }
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
namespace TableBooking.Model.Dtos.TableDtos
1+
using TableBooking.Model.Models;
2+
3+
namespace TableBooking.Model.Dtos.TableDtos
24
{
35
public class GetTablesDto
46
{
57
public Guid Id { get; set; }
68
public int NumberOfSeats { get; set; }
79
public Guid RestaurantId { get; set; }
10+
public IEnumerable<Booking>? Bookings { get; set; }
811
}
912
}

TableBookingAPI/TableBooking.Model/Dtos/TableDtos/TableDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace TableBooking.Model.Dtos.TableDtos
44
{
5-
public class TableDto : Entity
5+
public class TableDto
66
{
77
public int NumberOfSeats { get; set; }
88
public Guid RestaurantId { get; set; }

TableBookingAPI/TableBooking.Model/Models/Table.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ public class Table : Entity
55
public int NumberOfSeats { get; set; }
66
public Guid RestaurantId { get; set; }
77
public IEnumerable<Booking>? Bookings { get; set; }
8+
public Restaurant Restaurant { get; set; }
89
}
910
}

TableBookingAPI/TableBooking/Controllers/BookingController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public async Task<IActionResult> DeleteUserBooking(Guid id)
5656
return await _bookingService.DeleteBookingAsync(id, userId);
5757
}
5858

59-
[HttpPost("CreateBooking")]
60-
public async Task<IActionResult> CreateUserBooking([FromBody] CreateBookingDto bookingToCreateDto)
59+
[HttpPost("CreateBooking/{restaurantId}")]
60+
public async Task<IActionResult> CreateUserBooking([FromBody] CreateBookingDto bookingToCreateDto, Guid restaurantId)
6161
{
6262
var userId = Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
6363

64-
return await _bookingService.CreateBookingAsync(bookingToCreateDto, userId);
64+
return await _bookingService.CreateBookingAsync(bookingToCreateDto, userId, restaurantId);
6565
}
6666

6767
[HttpPut("UpdateBooking/{bookingId}")]

TableBookingAPI/TableBooking/Controllers/RestaurantController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ public async Task<IActionResult> CreateRestaurant([FromBody] RestaurantShortInfo
3535
return await _restaurantService.CreateRestaurantAsync(restaurantShortInfoDto);
3636
}
3737

38-
[HttpDelete("DeleteRestaurant/{id:int}")]
38+
[HttpDelete("DeleteRestaurant/{id:Guid}")]
3939
public async Task<IActionResult> DeleteRestaurant(Guid id)
4040
{
4141
return await _restaurantService.DeleteRestaurantAsync(id);
4242
}
4343

44-
[HttpPut("UpdateRestaurant")]
45-
public async Task<IActionResult> UpdateRestaurant()
44+
[HttpPut("UpdateRestaurant/{restaurantId}")]
45+
public async Task<IActionResult> UpdateRestaurant([FromBody] RestaurantShortInfoDto restaurantShortInfoDto, Guid restaurantId)
4646
{
47-
return Ok();
47+
return await _restaurantService.UpdateRestaurantAsync(restaurantShortInfoDto, restaurantId);
4848
}
4949

5050

TableBookingAPI/TableBooking/Controllers/TableController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public async Task<IActionResult> CreateTable([FromBody] TableDto tableDto)
3939
return await _tableService.CreateTableAsync(tableDto);
4040
}
4141

42-
[HttpPut("UpdateTable")]
43-
public async Task<IActionResult> UpdateTable([FromBody] TableDto tableDto)
42+
[HttpPut("UpdateTable/{tableId}")]
43+
public async Task<IActionResult> UpdateTable([FromBody] TableDto tableDto, Guid tableId)
4444
{
45-
return await _tableService.UpdateTableAsync(tableDto);
45+
return await _tableService.UpdateTableAsync(tableDto, tableId);
4646
}
4747

48-
[HttpDelete("DeleteTable/{id:int}")]
48+
[HttpDelete("DeleteTable/{id:Guid}")]
4949
public async Task<IActionResult> DeleteTable(Guid id)
5050
{
5151
return await _tableService.DeleteTableAsync(id);

TableBookingAPI/TableBooking/Interfaces/IBookingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public interface IBookingService
77
{
88
public Task<IActionResult> GetAllBookings(Guid userId);
99
public Task<IActionResult> GetBookingByIdAsync(Guid bookingId, Guid userId);
10-
public Task<IActionResult> CreateBookingAsync(CreateBookingDto createBookingDto, Guid userId);
10+
public Task<IActionResult> CreateBookingAsync(CreateBookingDto createBookingDto, Guid userId, Guid restaurantId);
1111
public Task<IActionResult> UpdateBookingAsync(UpdateBookingDto updateBookingDto, Guid userId, Guid bookingId);
1212
public Task<IActionResult> DeleteBookingAsync(Guid bookingId, Guid userId);
1313
}

0 commit comments

Comments
 (0)