ASP.NET MVC C# VS 2019 Can you please help me with the syntax error? I was trying to display the calendar on the top of the page but I made an error.
ASP.NET MVC C# VS 2019
Can you please help me with the syntax error? I was trying to display the calendar on the top of the page but I made an error.
@model List<AdventureDB.Models.CalendarItem>
@using System
@using System.Web.Mvc
@{
var weeks = (int)Math.Ceiling((double)(Model.Count + 13) / 7);
var startDate = Model.Count > 0 ? Model[0].Date : DateTime.Today;
var endDate = startDate.AddYears(4);
}
@using (Html.BeginForm("Index", "Home", FormMethod.Get))
{
<label for="startDate">Training Start Date:</label>
<input type="date" id="startDate" name="startDate" />
<input type="submit" value="Submit" />
}
@model IEnumerable<AdventureDB.Models.Training_Program>
@using AdventureDB.Models
@{
// Create an instance of the data context
var dbIEFW = new IEFWResourceDataContext();
var dbIFE = new IFEResourcesDataContext();
var dbREF = new REFDataContext();
var dbAQC = new AQCDataContext();
var dbAQCUSAF = new AQCUSAFDataContext();
var dbIPC = new IPCDataContext();
var dbIFTR = new IFTRDataContext();
var dbREFUSAF = new REFUSAFDataContext();
var dbIPCUSAF = new IPCUSAFResourcesDataContext();
int cntr = 0;
ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<style>
th {
color: white;
font-weight: bold;
font-style: normal;
font-family: "Times New Roman", Times, serif;
text-align: center;
}
td {
color: yellow;
font-weight: normal;
font-style: normal;
font-family: "Times New Roman", Times, serif;
text-align: center;
white-space: nowrap;
}
.calendar {
display: flex;
flex-direction: column;
width: max-content;
width: 620px;
}
.header {
display: flex;
justify-content: space-between;
background-color: lightgray;
padding: 5px;
}
.yellow-link {
color: yellow;
}
.horizontal-row-IEFW {
display: flex;
flex-direction: row;
color: blue;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-IFE {
display: flex;
flex-direction: row;
color: gainsboro;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-REF {
display: flex;
flex-direction: row;
color: aqua;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-REFUSAF {
display: flex;
flex-direction: row;
color: aquamarine;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-IFTR {
display: flex;
flex-direction: row;
color: beige;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-IPC {
display: flex;
flex-direction: row;
color: red;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-IPCUSAF {
display: flex;
flex-direction: row;
color: ActiveBorder;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-AQCUSAF {
display: flex;
flex-direction: row;
color: blueviolet;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row-AQC {
display: flex;
flex-direction: row;
color: pink;
font-weight: bold;
font-size: 20px;
font-family: "Times New Roman", Times, serif;
}
.horizontal-row span {
margin-right: 10px;
}
</style>
</head>
<body>
<div id="calendar"></div>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<div class="body" style="background-image: url('/Images/bckgrnd.JPG'); background-size: cover; background-position: center; background-repeat: no-repeat;">
@for (var i = 0; i < weeks; i++)
{
var weekStartDate = startDate.AddDays(i * 7);
var weekEndDate = weekStartDate.AddDays(4);
<div class="week">
<div class="day">
<div class="date">@weekStartDate.ToString("MMM d, yyyy")</div>
</div>
@for (var j = 0; j < 5; j++)
{
var index = i * 5 + j;
var currentDate = weekStartDate.AddDays(j);
if (currentDate <= endDate)
{
var dayName = currentDate.ToString("ddd").Substring(0, 3);
<div class="day @(Model[index].Style)">
<div class="date @(Model[index].Style.Contains("start-date") ? "start-date" : (Model[index].Style.Contains("end-date") ? "end-date" : ""))">
@dayName<br />
@currentDate.ToString("dd")
</div>
</div>
}
else
{
<div class="day"></div>
}
}
</div>
}
</div>
Step by step
Solved in 3 steps