public static async Task ShiftFromDate(IHttpContext context) { Server.ReadCookies(context).TryGetValue("MelBoxId", out string guid); if (!Server.LogedInHash.TryGetValue(guid, out Contact user)) { await Home(context); return; } bool isAdmin = user.Accesslevel >= Server.Level_Admin; var shiftDateStr = context.Request.PathParameters["shiftDate"]; DateTime.TryParse(shiftDateStr, out DateTime shiftDate); Shift shift = new Shift(user.Id, shiftDate); string contactOptions = Tab_Contact.HtmlOptionContacts(Server.Level_Reciever, shift.ContactId, isAdmin); DateTime endDate = shiftDate.DayOfWeek == DayOfWeek.Monday ? shiftDate.Date.AddDays(7) : shiftDate.Date.AddDays(1); Dictionary <string, string> pairs = new Dictionary <string, string> { // { "##readonly##", "readonly" }, { "##Id##", string.Empty }, { "##ContactOptions##", contactOptions }, { "##MinDate##", DateTime.UtcNow.Date.ToString("yyyy-MM-dd") }, { "##StartDate##", shiftDate.Date.ToString("yyyy-MM-dd") }, { "##EndDate##", endDate.ToString("yyyy-MM-dd") }, { "##StartOptions##", Tab_Shift.HtmlOptionHour(shift.Start.ToLocalTime().Hour) }, { "##EndOptions##", Tab_Shift.HtmlOptionHour(shift.End.ToLocalTime().Hour) }, { "##Route##", "new" } }; string form = Server.Page(Server.Html_FormShift, pairs); DataTable dt = Sql.Shift_View(); string table = Html.FromShiftTable(dt, user); await Server.PageAsync(context, "Bereitschaftsdienst", table + form); }
public static async Task ShiftFromId(IHttpContext context) { Server.ReadCookies(context).TryGetValue("MelBoxId", out string guid); bool isAdmin = false; if (Server.LogedInHash.TryGetValue(guid, out Contact user)) { isAdmin = user.Accesslevel >= Server.Level_Admin; } var shiftIdStr = context.Request.PathParameters["shiftId"]; int.TryParse(shiftIdStr, out int shiftId); Shift shift = Tab_Shift.Select(shiftId); string contactOptions = Tab_Contact.HtmlOptionContacts(Server.Level_Reciever, shift.ContactId, isAdmin); Dictionary <string, string> pairs = new Dictionary <string, string> { //{ "##readonly##", string.Empty }, { "##Id##", shift.Id.ToString() }, { "##ContactOptions##", contactOptions }, { "##MinDate##", DateTime.UtcNow.Date.ToString("yyyy-MM-dd") }, { "##StartDate##", shift.Start.ToLocalTime().ToString("yyyy-MM-dd") }, { "##EndDate##", shift.End.ToLocalTime().ToString("yyyy-MM-dd") }, { "##StartOptions##", Tab_Shift.HtmlOptionHour(shift.Start.ToLocalTime().Hour) }, { "##EndOptions##", Tab_Shift.HtmlOptionHour(shift.End.ToLocalTime().Hour) }, { "##Route##", "update" } }; string form = Server.Page(Server.Html_FormShift, pairs); DataTable dt = Sql.Shift_View(); string table = Html.FromShiftTable(dt, user); await Server.PageAsync(context, "Bereitschaftsdienst", table + form); }