I have a user that can create multiple time sheets at a time each if a user creates a timesheet and creates more than 1 project at 1 time it will create separate timesheetdetails for each project but they will all have the same timesheetmaster.
How can I specifically pick each timesheetdetail when a user clicks on each one separately.
Right now I’m using firstordefault and it will only pick the first one even when you click on a 2nd one and are trying to get the second ones details
I may have had a lil trouble explaining this and maybe I have a design issue in my view but here is my code it has a list of all the records but can only select 1 if more than 1 has the same masterID but every detailId is different.
//GET: /TimeSheet/UserTimeDetails/{uid}{tid}
public async Task<ActionResult> UserTimeDetails(string uid, int tid)
{
var tmaster = await context.TimeSheetMaster.Where(t =>
t.TimeSheetMasterId == tid).FirstOrDefaultAsync();
var tdetail = await context.TimeSheetDetails.Where(t =>
t.TimeSheetMasterId == tmaster.TimeSheetMasterId).FirstOrDefaultAsync();
var project = await context.Projects.Where(p =>
p.ProjectId == tdetail.ProjectId).FirstOrDefaultAsync();
var userTimeDetails = (from t in context.TimeSheetMaster
join d in context.TimeSheetDetails
on t.TimeSheetMasterId equals d.TimeSheetMasterId
where t.UserId == uid
select new TimeSheetDetailsModel()
{
TimeSheetMasterId = t.TimeSheetMasterId,
Sunday = d.Sunday,
Monday = d.Monday,
Tuesday = d.Tuesday,
Wednesday = d.Wednesday,
Thursday = d.Thursday,
Friday = d.Friday,
Saturday = d.Saturday,
Hours = t.TotalHours,
ProjectName = project.ProjectName,
ProjectId = project.ProjectId,
UserId = t.UserId,
Comment = t.Comment
});
if (userTimeDetails == null)
return HttpNotFound();
return View(await userTimeDetails.FirstOrDefaultAsync());
}
<td>
@Html.ActionLink("Details", "UserTimeDetails",
new { uid = item.UserId, tid = item.TimeSheetMasterId },
new { @class = "btn btn-info" })
</td>