Пример #1
0
        public IHttpContext ResponseAccount(IHttpContext context)
        {
            string caption = "Benutzerkonto";
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            Dictionary <string, string> action = new Dictionary <string, string>
            {
                { "/account/update", "Änderungen an Kontakt speichern" }
            };

            if (isAdmin)
            {
                action.Add("/account/create", "Neuen Kontakt mit diesen Angaben einrichten");
                action.Add("/account/delete", "Diesen Kontakt löschen");
            }

            StringBuilder builder = new StringBuilder();

            int chosenContactId = logedInUserId;

            if (requestingPage == caption && args.ContainsKey("selectedContactId")) //Ist Antwort von dieser Seite
            {
                int.TryParse(args["selectedContactId"].ToString(), out chosenContactId);
            }
            else if (chosenContactId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Ungültiger Aufruf", "Für Einsicht in das Benutzerkonto bitte einloggen."));
            }

            if (logedInUserId != 0)
            {
                DataTable dt;
                if (isAdmin)
                {
                    dt = Program.Sql.GetViewContactInfo();
                }
                else
                {
                    dt = Program.Sql.GetViewContactInfo(chosenContactId);
                }

                DataTable dtCompany = Program.Sql.GetCompany();

                builder.Append(MelBoxWeb.HtmlFormAccount(dt, dtCompany, chosenContactId, isAdmin));
            }
#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), caption, logedInUserName));
            return(context);
        }
Пример #2
0
        public IHttpContext ResponseAccountUpdate(IHttpContext context)
        {
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder         = new StringBuilder();
            int           chosenContactId = MelBoxWeb.GetArgInt(args, "ContactId");

            if (!isAdmin && chosenContactId != logedInUserId)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie haben keine Berechtigung den Benutzer zu ändern."));
            }
            else
            {
                builder.Append(MelBoxWeb.ProcessFormAccount(args, false));
            }

            if (logedInUserId != 0)
            {
                DataTable dt;
                if (isAdmin)
                {
                    dt = Program.Sql.GetViewContactInfo();
                }
                else
                {
                    dt = Program.Sql.GetViewContactInfo(chosenContactId);
                }

                DataTable dtCompany = Program.Sql.GetCompany();

                builder.Append(MelBoxWeb.HtmlFormAccount(dt, dtCompany, chosenContactId, isAdmin));
            }

#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Benutzerkonto ändern", logedInUserName));
            return(context);
        }