I have a controller action that is pulling data to a view. Some of the data is showing well most of it is but than all the hours for the week isn’t showing. I’m very confused as to why some of it is working and the other isn’t. Al my weekday hours are not showing BUT the weekday total hours shows the comment/desc show. The proj name shows…. I tried a few different ways to get these hours to work but I have not had any luck…..
Here is my code
action method
public async Task<ActionResult> UserEditTimeSheet(string uid,int mid)
{
ViewBag.ProjectsSelect = new SelectList(
context.Projects.ToList(), "ProjectId", "ProjectName");
var tmaster = await context.TimeSheetMaster.Where(m => m.TimeSheetMasterId
== mid && m.UserId == uid).FirstOrDefaultAsync();
var tdetail = await context.TimeSheetDetails.Where(d => d.TimeSheetMasterId
== tmaster.TimeSheetMasterId).FirstOrDefaultAsync();
var tproj = await context.Projects.Where(p => p.ProjectId
== tdetail.ProjectId).FirstOrDefaultAsync();
var timeSheet = (from t in context.TimeSheetMaster
join d in context.TimeSheetDetails
on t.TimeSheetMasterId equals d.TimeSheetMasterId
where d.TimeSheetMasterId == mid
&& d.TimeSheetId == tdetail.TimeSheetId
select new TimeSheetProjectsModel()
{
TimeMasterId = t.TimeSheetMasterId,
TimeDetailsId = d.TimeSheetId,
P1w1d1 = d.Sunday,
P1w1d2 = d.Monday,
P1w1d3 = d.Tuesday,
P1w1d4 = tdetail.Wednesday,//d.Wednesday,
P1w1d5 = tdetail.Thursday,//d.Thursday,
P1w1d6 = tdetail.Friday,//d.Friday,
P1w1d7 = tdetail.Saturday,//d.Saturday,
ProjTotal1 = (int)t.TotalHours,
DaysOfWeek1 = tproj.ProjectName,
ProjectId1 = tproj.ProjectId,
UserId = t.UserId,
ProjDesc1 = t.Comment
});
if (timeSheet == null)
return HttpNotFound();
return View(await timeSheet.FirstOrDefaultAsync());
part if view showing how my view is
<div class="col-md-2 form-group">
@Html.DropDownListFor(p => p.ProjectId1,
(SelectList)ViewBag.ProjectsSelect, " ",
new { @class = "form-control" })
@Html.ValidationMessageFor(p=>p.ProjectId1, "",
new { @class = "text-danger" })
</div>
<div class="col-md-1 form-group">
@Html.TextBoxFor(d => d.P1w1d1, new { @class = "form-control",
@onblur = "Proj1Tot()", @maxlength = "2", @Value = "0" })
@Html.ValidationMessageFor(d => d.P1w1d1, "", new { @class = "text-danger" })
</div>
<div class="col-md-1 form-group">
@Html.TextBoxFor(d => d.P1w1d2, new { @class = "form-control",
@onblur = "Proj1Tot()", @maxlength = "2", @Value = "0" })
@Html.ValidationMessageFor(d => d.P1w1d2, "", new { @class = "text-danger" })
</div>