full CRUD (75%)
This commit is contained in:
parent
ee84c3e108
commit
e7f2e4d4d9
@ -125,7 +125,7 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View(APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunchlist?headwaiterId={APIClient.Headwaiter.Id}"));
|
return View(APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunches?headwaiterId={APIClient.Headwaiter.Id}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult CreateLunch()
|
public IActionResult CreateLunch()
|
||||||
@ -171,7 +171,7 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunchlist?headwaiterId={APIClient.Headwaiter.Id}");
|
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunches?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunchlist?headwaiterId={APIClient.Headwaiter.Id}");
|
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunches?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}");
|
ViewBag.Rooms = APIClient.GetRequest<List<RoomViewModel>>($"api/room/getrooms?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,45 +377,37 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View(APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferencebooking/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}"));
|
return View(APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferencebooking/getconferenceBookings?headwaiterId={APIClient.Headwaiter.Id}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Tuple<ConferenceBookingViewModel, string>? GetConferenceBooking(int conferenceBookingId)
|
public Tuple<RoomViewModel, List<string>>? GetConferenceBooking(int conferencebookingId)
|
||||||
{
|
{
|
||||||
if (APIClient.Headwaiter == null)
|
if (APIClient.Headwaiter == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Необходима авторизация");
|
throw new Exception("Необходима авторизация");
|
||||||
}
|
}
|
||||||
var result = APIClient.GetRequest<Tuple<ConferenceBookingViewModel, List<Tuple<string, string>>>>($"api/conferencebooking/getconferenceBooking?conferenceBookingId={conferenceBookingId}");
|
var result = APIClient.GetRequest<Tuple<RoomViewModel, List<string>>>($"api/conferencebooking/getconferencebooking?conferencebookingId={conferencebookingId}");
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
string table = "";
|
|
||||||
for (int i = 0; i < result.Item2.Count; i++)
|
|
||||||
{
|
|
||||||
var lunchName = result.Item2[i].Item1;
|
|
||||||
var lunchPrice = result.Item2[i].Item2;
|
|
||||||
table += "<tr style=\"height: 44px\">";
|
|
||||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{lunchName}</td>";
|
|
||||||
table += $"<td class=\"u-border-1 u-border-grey-30 u-table-cell\">{lunchPrice}</td>";
|
|
||||||
table += "</tr>";
|
|
||||||
}
|
|
||||||
return Tuple.Create(result.Item1, table);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IActionResult CreateConferenceBooking()
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult CreateConferenceBooking()
|
||||||
{
|
{
|
||||||
if (APIClient.Headwaiter == null)
|
if (APIClient.Headwaiter == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
|
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunches?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateConferenceBooking(string nameHall)
|
public void CreateConferenceBooking(string nameHall, DateTime bookingDate, List<int> lunches)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(nameHall))
|
if (string.IsNullOrEmpty(nameHall))
|
||||||
{
|
{
|
||||||
@ -425,11 +417,17 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Необходима авторизация");
|
throw new Exception("Необходима авторизация");
|
||||||
}
|
}
|
||||||
|
Dictionary<int, ILunchModel> a = new Dictionary<int, ILunchModel>();
|
||||||
|
foreach (int lunch in lunches)
|
||||||
|
{
|
||||||
|
a.Add(lunch, new LunchSearchModel { Id = lunch } as ILunchModel);
|
||||||
|
}
|
||||||
APIClient.PostRequest("api/conferencebooking/createconferenceBooking", new ConferenceBookingBindingModel
|
APIClient.PostRequest("api/conferencebooking/createconferenceBooking", new ConferenceBookingBindingModel
|
||||||
{
|
{
|
||||||
NameHall = nameHall,
|
NameHall = nameHall,
|
||||||
HeadwaiterId = APIClient.Headwaiter.Id,
|
BookingDate = bookingDate,
|
||||||
|
HeadwaiterId = APIClient.Headwaiter.Id,
|
||||||
|
ConferenceBookingLunches = a
|
||||||
});
|
});
|
||||||
Response.Redirect("ListConferenceBookings");
|
Response.Redirect("ListConferenceBookings");
|
||||||
}
|
}
|
||||||
@ -440,13 +438,13 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferencebooking/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}");
|
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferencebooking/getconferenceBookings?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
ViewBag.Conferences = APIClient.GetRequest<List<ConferenceViewModel>>($"api/conference/getconferences");
|
ViewBag.Lunches = APIClient.GetRequest<List<LunchViewModel>>($"api/lunch/getlunches?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateConferenceBooking(int conference, int conferenceBooking, string nameHall, DateTime bookingDate)
|
public void UpdateConferenceBooking(int conferenceBooking, string nameHall, DateTime bookingDate, List<int> lunches)
|
||||||
{
|
{
|
||||||
if (APIClient.Headwaiter == null)
|
if (APIClient.Headwaiter == null)
|
||||||
{
|
{
|
||||||
@ -456,13 +454,18 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Название не может быть пустым");
|
throw new Exception("Название не может быть пустым");
|
||||||
}
|
}
|
||||||
|
Dictionary<int, ILunchModel> a = new Dictionary<int, ILunchModel>();
|
||||||
|
foreach (int lunch in lunches)
|
||||||
|
{
|
||||||
|
a.Add(lunch, new LunchSearchModel { Id = lunch } as ILunchModel);
|
||||||
|
}
|
||||||
APIClient.PostRequest("api/conferencebooking/updateconferenceBooking", new ConferenceBookingBindingModel
|
APIClient.PostRequest("api/conferencebooking/updateconferenceBooking", new ConferenceBookingBindingModel
|
||||||
{
|
{
|
||||||
Id = conferenceBooking,
|
Id = conferenceBooking,
|
||||||
NameHall = nameHall,
|
NameHall = nameHall,
|
||||||
BookingDate = bookingDate,
|
BookingDate = bookingDate,
|
||||||
HeadwaiterId = APIClient.Headwaiter.Id,
|
HeadwaiterId = APIClient.Headwaiter.Id,
|
||||||
ConferenceId = conference
|
ConferenceBookingLunches = a
|
||||||
});
|
});
|
||||||
Response.Redirect("ListConferenceBookings");
|
Response.Redirect("ListConferenceBookings");
|
||||||
}
|
}
|
||||||
@ -473,7 +476,7 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferencebooking/getconferenceBookinglist?headwaiterId={APIClient.Headwaiter.Id}");
|
ViewBag.ConferenceBookings = APIClient.GetRequest<List<ConferenceBookingViewModel>>($"api/conferencebooking/getconferenceBookings?headwaiterId={APIClient.Headwaiter.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,27 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавление бронирования по конференции</h2>
|
<h2 class="display-4">Добавление бронирования по конференции</h2>
|
||||||
</div>
|
</div>
|
||||||
<input type="text"
|
<div class="form-group">
|
||||||
placeholder="Введите название зала"
|
<label for="nameHall">Название зала:</label>
|
||||||
name="nameHall"
|
<input type="text" id="nameHall" name="nameHall" class="form-control" placeholder="Введите название зала">
|
||||||
class="form-control" />
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="bookingDate">Дата:</label>
|
||||||
|
<input type="datetime-local" id="bookingDate" name="bookingDate" class="form-control" placeholder="Выберите начало конференции">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="u-label u-text-custom-color-1 u-label-2">Обеды</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="lunches" class="form-control" multiple size="6" id="lunches">
|
||||||
|
@foreach (var lunch in ViewBag.Lunches)
|
||||||
|
{
|
||||||
|
<option value="@lunch.Id">@lunch.LunchName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="u-container-layout u-container-layout-2">
|
<div class="u-container-layout u-container-layout-2">
|
||||||
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center d-flex justify-content-md-center" />
|
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center d-flex justify-content-md-center" />
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавление обеда</h2>
|
<h2 class="display-4">Добавление обеда</h2>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="u-label u-text-custom-color-1 u-label-2">Название обеда</label>
|
||||||
|
</div>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
placeholder="Введите название обеда"
|
placeholder="Введите название обеда"
|
||||||
name="lunchName"
|
name="lunchName"
|
||||||
|
@ -13,10 +13,6 @@
|
|||||||
<label for="conferenceBooking">Бронирование:</label>
|
<label for="conferenceBooking">Бронирование:</label>
|
||||||
<select id="conferenceBooking" name="conferenceBooking" class="form-control" asp-items="@(new SelectList(@ViewBag.ConferenceBookings, "Id", "NameHall"))"></select>
|
<select id="conferenceBooking" name="conferenceBooking" class="form-control" asp-items="@(new SelectList(@ViewBag.ConferenceBookings, "Id", "NameHall"))"></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="conference">Конференция:</label>
|
|
||||||
<select id="conference" name="conference" class="form-control" asp-items="@(new SelectList(@ViewBag.Conferences, "Id", "ConferenceName"))"></select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="nameHall">Название зала:</label>
|
<label for="nameHall">Название зала:</label>
|
||||||
<input type="text" id="nameHall" name="nameHall" class="form-control" placeholder="Введите название зала">
|
<input type="text" id="nameHall" name="nameHall" class="form-control" placeholder="Введите название зала">
|
||||||
@ -26,18 +22,16 @@
|
|||||||
<input type="datetime-local" id="bookingDate" name="bookingDate" class="form-control" placeholder="Выберите начало конференции">
|
<input type="datetime-local" id="bookingDate" name="bookingDate" class="form-control" placeholder="Выберите начало конференции">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Обеды для бронирования:</label>
|
<label class="u-label u-text-custom-color-1 u-label-2">Обеды</label>
|
||||||
<div class="table-responsive">
|
</div>
|
||||||
<table class="table">
|
<div class="form-group">
|
||||||
<thead class="thead-dark">
|
<div class="col-8">
|
||||||
<tr>
|
<select name="lunches" class="form-control" multiple size="6" id="lunches">
|
||||||
<th>Обед</th>
|
@foreach (var lunch in ViewBag.Lunches)
|
||||||
<th>Цена</th>
|
{
|
||||||
</tr>
|
<option value="@lunch.Id">@lunch.LunchName</option>
|
||||||
</thead>
|
}
|
||||||
<tbody id="table-elements" class="u-table-body">
|
</select>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
@ -58,7 +52,11 @@
|
|||||||
data: { conferenceBookingId: conferenceBooking },
|
data: { conferenceBookingId: conferenceBooking },
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
$('#nameHall').val(result.item1.nameHall);
|
$('#nameHall').val(result.item1.nameHall);
|
||||||
$('#table-elements').html(result.item2);
|
$('#bookingDate').val(result.item1.bookingDate);
|
||||||
|
$.map(result.item2, function (n) {
|
||||||
|
console.log("#" + n);
|
||||||
|
$("#" + n).attr("selected", "selected")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user