public IHttpContext ResponseShift(IHttpContext context) { string payload = context.Request.Payload; Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload); ReadGlobalFields(args); #region Tabelle anzeigen Dictionary <string, string> action = new Dictionary <string, string> { { "/shift/edit", "Bereitschaft bearbeiten" } }; if (isAdmin) { action.Add("/shift/delete", "Bereitschaft löschen"); } DataTable dt = Program.Sql.GetViewShift(); StringBuilder builder = new StringBuilder(); builder.Append(MelBoxWeb.HtmlTableShift(dt, 0, logedInUserId, isAdmin)); builder.Append(MelBoxWeb.HtmlEditor(action)); #endregion #if DEBUG builder.Append("<p class='w3-pink'>" + payload + "</p>"); #endif context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName)); return(context); }
public IHttpContext ResponseShiftCreateOrUpdate(IHttpContext context) { string payload = context.Request.Payload; Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload); ReadGlobalFields(args); StringBuilder builder = new StringBuilder(); if (logedInUserId == 0) { builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler", "Der eingeloggte Benutzer konnte nicht zugeordnet werden.")); } else { builder.Append(MelBoxWeb.ProcessFormShift(args, logedInUserId, isAdmin)); } #region Tabelle anzeigen Dictionary <string, string> action = new Dictionary <string, string> { { "/shift/edit", "Bereitschaft bearbeiten" } }; if (isAdmin) { action.Add("/shift/delete", "Bereitschaft löschen"); } DataTable dt = Program.Sql.GetViewShift(); builder.Append(MelBoxWeb.HtmlTableShift(dt, 0, logedInUserId, isAdmin)); builder.Append(MelBoxWeb.HtmlEditor(action)); #endregion #if DEBUG builder.Append("<p class='w3-pink'>" + payload + "</p>"); #endif context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Bereitschaft erstellen", logedInUserName)); return(context); }
public IHttpContext ResponseShiftDelete(IHttpContext context) { string payload = context.Request.Payload; Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload); ReadGlobalFields(args); StringBuilder builder = new StringBuilder(); int shiftId = 0; if (args.ContainsKey("selectedRow")) { int.TryParse(args["selectedRow"].ToString(), out shiftId); } if (logedInUserId == 0) { builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler", "Der eingeloggte Benutzer konnte nicht zugeordnet werden.")); } else if (!isAdmin) { builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie besitzen nicht die notwendigen Rechte für diese Aktion.")); } else if (shiftId == 0) { builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Bereitschaft löschen", "Fehlerhafter Aufruf. Die zu löschende Bereitschaft konnte nicht zugeordnet werden.")); } else { if (!Program.Sql.DeleteShift(shiftId)) { builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Bereitschaft Nr. " + shiftId + " löschen", string.Format("Die Bereitschaft konnte nicht aus der Datenbank gelöscht werden."))); } else { string msg = string.Format("Die Bereitschaft Nr. {0} wurde durch den Benutzer '{1}' gelöscht.", shiftId, logedInUserName); builder.Append(MelBoxWeb.HtmlAlert(3, "Bereitschaft Nr. " + shiftId + " gelöscht", msg)); Program.Sql.Log(MelBoxSql.LogTopic.Shift, MelBoxSql.LogPrio.Warning, msg); } } #region Tabelle anzeigen Dictionary <string, string> action = new Dictionary <string, string> { { "/shift/edit", "Bereitschaft bearbeiten" } }; if (isAdmin) { action.Add("/shift/delete", "Bereitschaft löschen"); } DataTable dt = Program.Sql.GetViewShift(); builder.Append(MelBoxWeb.HtmlTableShift(dt, 0, logedInUserId, isAdmin)); builder.Append(MelBoxWeb.HtmlEditor(action)); #endregion #if DEBUG builder.Append("<p class='w3-pink'>" + payload + "</p>"); #endif context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Bereitschaft löschen", logedInUserName)); return(context); }