add get user contracted hours procedure to supply the TimeLogList object HoursPerWeekMinutes property.
started databinding the timelogs page. #15
This commit is contained in:
parent
8020cd3801
commit
8756964f0b
@ -15,7 +15,8 @@ namespace Interfaces
|
|||||||
public int TimeLogCount { get { return TimeLogs.Values.Sum(x => x.LogCount); } }
|
public int TimeLogCount { get { return TimeLogs.Values.Sum(x => x.LogCount); } }
|
||||||
public Dictionary<DayOfWeek,DailyLogs> TimeLogs { get; set; }
|
public Dictionary<DayOfWeek,DailyLogs> TimeLogs { get; set; }
|
||||||
public double WeeklyTotal {
|
public double WeeklyTotal {
|
||||||
get { return TimeLogs.Values.Sum(x => x.DailyTotal)/60.0d; }
|
get { return TimeLogs.Values.Sum(x => x.DailyTotal); }
|
||||||
}
|
}
|
||||||
|
public float HoursPerWeekMinutes { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,5 +22,7 @@ namespace SQLiteRepository
|
|||||||
public const string GET_ALL_USERS_PAGINATE = "select * from "+ nameof(UserIdentity)+" limit ? offset ?";
|
public const string GET_ALL_USERS_PAGINATE = "select * from "+ nameof(UserIdentity)+" limit ? offset ?";
|
||||||
|
|
||||||
public const string GET_TOTAL_USER_COUNT = "select Max("+nameof(UserIdentity.Id)+") from " + nameof(UserIdentity);
|
public const string GET_TOTAL_USER_COUNT = "select Max("+nameof(UserIdentity.Id)+") from " + nameof(UserIdentity);
|
||||||
|
|
||||||
|
public const string GET_USER_CONTRACTED_HOURS = "select "+nameof(UserIdentity.HoursPerWeek)+ " From UserIdentity where " + nameof(UserIdentity.Id) + "=?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,25 +168,10 @@ namespace SQLiteRepository
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
//TODO: refac this as it duplicates a lot of code.
|
||||||
public TimeLogList GetTimeLogs(int userId)
|
public TimeLogList GetTimeLogs(int userId)
|
||||||
{
|
{
|
||||||
var ret = new TimeLogList();
|
return GetTimeLogs(userId, DateTime.UtcNow);
|
||||||
//get this calendar week;
|
|
||||||
var now = DateTime.UtcNow;
|
|
||||||
var calendarWeek = GetIso8601CalendarWeek(now);
|
|
||||||
ret.CalendarWeek = calendarWeek;
|
|
||||||
ret.SelectedDate = now.Date;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ret.TimeLogs = GetTimeLogList(userId, calendarWeek, now.Year);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.Error(ex, "Error in GetTimeLogs with Id: {0}, Exception: {1}", userId, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeLogList GetTimeLogs(int userId, DateTime selectedDate)
|
public TimeLogList GetTimeLogs(int userId, DateTime selectedDate)
|
||||||
@ -204,9 +189,28 @@ namespace SQLiteRepository
|
|||||||
_logger.Error(ex, "Error in GetTimeLogs with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex);
|
_logger.Error(ex, "Error in GetTimeLogs with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ret.HoursPerWeekMinutes = GetUserContractedHours(userId)*60.0f;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "Error in GetUserContracterHours with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float GetUserContractedHours(int userId)
|
||||||
|
{
|
||||||
|
var hoursQuery = _connection.Query<UserIdentity>(SQLiteProcedures.GET_USER_CONTRACTED_HOURS, userId);
|
||||||
|
if (hoursQuery.Any())
|
||||||
|
{
|
||||||
|
return hoursQuery.First().HoursPerWeek;
|
||||||
|
}
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
public IdentifierList GetUnassignedIdentifierList()
|
public IdentifierList GetUnassignedIdentifierList()
|
||||||
{
|
{
|
||||||
var ret = new IdentifierList();
|
var ret = new IdentifierList();
|
||||||
|
|||||||
@ -205,6 +205,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-9 col-xs-12 well">
|
<div class="col-md-9 col-xs-12 well">
|
||||||
<!-- main content panel. -->
|
<!-- main content panel. -->
|
||||||
|
<label data-bind="text: CalendarWeek"></label>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -219,60 +220,22 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<!-- ko foreach: TimeLogs-->
|
||||||
<td class="valign" for="monday">Monday</td>
|
<tr>
|
||||||
<td class="valign" for="timein1"></td>
|
<td class="valign">Monday</td>
|
||||||
<td class="valign" for="timeout1"></td>
|
<td class="valign" data-bind="text: TimeLogCount"></td>
|
||||||
<td class="valign" for="timein2"></td>
|
<td class="valign"></td>
|
||||||
<td class="valign" for="timeout2"></td>
|
<td class="valign"></td>
|
||||||
<td class="valign" for="timein3"></td>
|
<td class="valign"></td>
|
||||||
<td class="valign" for="timeout3"></td>
|
<td class="valign"></td>
|
||||||
<td class="valign" for="dailyHrsTotal">8</td>
|
<td class="valign"></td>
|
||||||
</tr>
|
<td class="valign">8</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td class="valign" for="monday">Tuesday</td>
|
<!-- /ko -->
|
||||||
<td class="valign" for="timein1"></td>
|
<tr>
|
||||||
<td class="valign" for="timeout1"></td>
|
<td class="valign" colspan="7" for="monday">Weekly Total</td>
|
||||||
<td class="valign" for="timein2"></td>
|
<td class="valign" for="dailyHrsTotal" data-bind="rext: WeeklyTotal"></td>
|
||||||
<td class="valign" for="timeout2"></td>
|
</tr>
|
||||||
<td class="valign" for="timein3"></td>
|
|
||||||
<td class="valign" for="timeout3"></td>
|
|
||||||
<td class="valign" for="dailyHrsTotal">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="valign" for="monday">Wednesday</td>
|
|
||||||
<td class="valign" for="timein1"></td>
|
|
||||||
<td class="valign" for="timeout1"></td>
|
|
||||||
<td class="valign" for="timein2"></td>
|
|
||||||
<td class="valign" for="timeout2"></td>
|
|
||||||
<td class="valign" for="timein3"></td>
|
|
||||||
<td class="valign" for="timeout3"></td>
|
|
||||||
<td class="valign" for="dailyHrsTotal">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="valign" for="monday">Thursday</td>
|
|
||||||
<td class="valign" for="timein1"></td>
|
|
||||||
<td class="valign" for="timeout1"></td>
|
|
||||||
<td class="valign" for="timein2"></td>
|
|
||||||
<td class="valign" for="timeout2"></td>
|
|
||||||
<td class="valign" for="timein3"></td>
|
|
||||||
<td class="valign" for="timeout3"></td>
|
|
||||||
<td class="valign" for="dailyHrsTotal">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="valign" for="monday">Friday</td>
|
|
||||||
<td class="valign" for="timein1"></td>
|
|
||||||
<td class="valign" for="timeout1"></td>
|
|
||||||
<td class="valign" for="timein2"></td>
|
|
||||||
<td class="valign" for="timeout2"></td>
|
|
||||||
<td class="valign" for="timein3"></td>
|
|
||||||
<td class="valign" for="timeout3"></td>
|
|
||||||
<td class="valign" for="dailyHrsTotal">8</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="valign" colspan="7" for="monday">Weekly Total</td>
|
|
||||||
<td class="valign" for="dailyHrsTotal">37</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user