Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- ViewBag.Title = "Home Page";
- var times = new List<string>()
- {
- "07:30",
- "08:00",
- "08:30",
- "09:00",
- "09:30",
- "10:00",
- "10:30",
- "11:00",
- "11:30",
- "12:00",
- "12:30"
- };
- }
- <script type="text/javascript">
- $( "#button" ).click(function() {
- $( "#item" ).toggle();
- });
- </script>
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css …" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
- <h2>KalendarTool</h2>
- <table class="table table-bordered table-striped" id="reservationCalendar" align="center" frame="border" style="width:100%">
- <tr>
- @{
- int currentMonth = DateTime.Now.Month;
- <td style="width:14%"></td>
- for (int month = 0; month < 12; month++)
- {
- int currentYear = DateTime.Now.Year;
- DateTime firstDay = new DateTime(DateTime.Now.Year, currentMonth, 1);
- int daysInCurrentMonth = DateTime.DaysInMonth(firstDay.Year, firstDay.Month);
- DateTime lastDay = new DateTime(currentYear, currentMonth, daysInCurrentMonth);
- // Sunday casted to int gives 0 but that will not work for us, we need 7 to be able to calculate number of empty cells correctly
- int dayOfWeekFirst = ((int)firstDay.DayOfWeek > 0) ? (int)firstDay.DayOfWeek : 7;
- int dayOfWeekLast = ((int)lastDay.DayOfWeek > 0) ? (int)lastDay.DayOfWeek : 7;
- for (int i = 1; i <= daysInCurrentMonth; i++)
- {
- DateTime renderedDay = new DateTime(firstDay.Year, firstDay.Month, i);
- String DayDate = renderedDay.ToString("dd.MM.yyyy");
- if (renderedDay < DateTime.Now )
- {
- <td class="alert alert-danger" style="width: 14%">
- @renderedDay.DayOfWeek, @DayDate <a id="button" href="#">▼</a>
- <table id="item" style="background: white; width: 100%; padding: 0px; margin: 0px;">
- @foreach (string timeOfDay in times)
- {
- <tr>
- <td>
- <span>@timeOfDay<input type="button" value="BOOK" style="margin-left: 15px"><input/></span>
- </td>
- </tr>
- }
- </table>
- </td>
- }
- else
- {
- <td class="alert alert-success" style="width:14%">
- @renderedDay.DayOfWeek, @DayDate
- <table id="item" style="background: white; width: 100%; padding: 0px; margin: 0px;">
- @foreach (string timeOfDay in times)
- {
- <tr>
- <td>
- <span>@timeOfDay<input type="button" value="BOOK" style="margin-left: 15px"><input /></span>
- </td>
- </tr>
- }
- </table>
- </td>
- }
- if (renderedDay.DayOfWeek == DayOfWeek.Sunday)
- {
- @:</tr>
- @:</table>
- @:<table class="table table-bordered table-striped" id="reservationCalendar" align="center" frame="border" style="width:100%">
- @:<tr>
- }
- }
- currentMonth = currentMonth + 1;
- }
- }
- </tr>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement