Пример #1
0
        public static async Task CompanyShow(IHttpContext context)
        {
            #region Anfragenden Firma identifizieren
            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;
            int showId   = 0;

            if (context.Request.PathParameters.TryGetValue("id", out string idStr))
            {
                int.TryParse(idStr, out showId);
            }

            Company company = MelBoxSql.Tab_Company.SelectCompany(showId);
            #endregion

            Dictionary <string, string> pairs = new Dictionary <string, string>
            {
                { "##readonly##", isAdmin ? string.Empty : "readonly" },
                { "##disabled##", isAdmin ? string.Empty : "disabled" },
                { "##Id##", company.Id.ToString() },
                { "##Name##", company.Name },
                { "##Address##", company.Address },
                { "##City##", company.City },

                { "##NewCompany##", isAdmin ? Html.ButtonNew("company") : string.Empty },
                { "##DeleteCompany##", isAdmin ? Html.ButtonDelete("company", company.Id) : string.Empty }
            };

            string form = Server.Page(Server.Html_FormCompany, pairs);

            DataTable dt = Tab_Company.SelectCompanyAll(isAdmin ? 0 : company.Id);
            string table = Html.FromTable(dt, true, "company");

            await Server.PageAsync(context, "Firmeninformation", table + form);
        }
Пример #2
0
        public static async Task Register(IHttpContext context)
        {
            Dictionary <string, string> payload = Server.Payload(context);

            payload.TryGetValue("name", out string name);
            //payload.TryGetValue("password", out string password); //Sicherheit!

            Dictionary <string, string> pairs = new Dictionary <string, string>
            {
                { "##readonly##", "readonly" },
                { "##disabled##", string.Empty },
                { "##Name##", name },
                { "##CompanyList##", Tab_Company.SelectCompanyAllToHtmlOption() },
                { "##NewContact##", Html.ButtonNew("account") }
            };

            string form = Server.Page(Server.Html_FormRegister, pairs);

            await Server.PageAsync(context, "Benutzerregistrierung", form);
        }
Пример #3
0
        public static async Task CompanyDelete(IHttpContext context)
        {
            #region Anfragenden Benutzer identifizieren
            Server.ReadCookies(context).TryGetValue("MelBoxId", out string guid);

            if (guid == null || !Server.LogedInHash.TryGetValue(guid, out Contact user))
            {
                await Home(context);

                return;
            }
            #endregion
            bool isAdmin = user.Accesslevel >= Server.Level_Admin;
            string html  = Html.Alert(1, "Fehlerhafter Parameter", "Aufruf mit fehlerhaftem Parameter.");

            if (context.Request.PathParameters.TryGetValue("id", out string idStr))
            {
                if (!isAdmin || !int.TryParse(idStr, out int deleteId))
                {
                    html = Html.Alert(2, "Keine Berechtigung", $"Keine Berechtigung zum Löschen von Firmeninformationen.");
                }
                else
                {
                    Company company = Tab_Company.SelectCompany(deleteId);

                    if (!Tab_Company.Delete(company))
                    {
                        html = Html.Alert(2, "Löschen fehlgeschlagen", $"Löschen der Firma [{deleteId}] >{company.Name}< >{company.City}< fehlgeschlagen.");
                    }
                    else
                    {
                        html = Html.Alert(1, "Firma gelöscht", $"Die Firma [{deleteId}] >{company.Name}< >{company.City}< wurde aus der Datenbank gelöscht.");
                    }
                }
            }

            await Server.PageAsync(context, "Firma löschen", html);
        }
Пример #4
0
        public static async Task AccountShow(IHttpContext context)
        {
            #region Anfragenden Benutzer identifizieren
            Server.ReadCookies(context).TryGetValue("MelBoxId", out string guid);

            if (guid == null || !Server.LogedInHash.TryGetValue(guid, out Contact user))
            {
                await Home(context);

                return;
            }

            bool isAdmin = user.Accesslevel >= Server.Level_Admin;
            DataTable dt = Tab_Contact.SelectContactList(user.Accesslevel, isAdmin ? 0 : user.Id);
            #endregion

            #region Anzuzeigenden Benutzer
            int showId = user.Id;

            if (context.Request.PathParameters.TryGetValue("id", out string idStr))
            {
                int.TryParse(idStr, out showId);
            }

            Contact account = MelBoxSql.Tab_Contact.SelectContact(showId);
            Company company = MelBoxSql.Tab_Company.SelectCompany(account.CompanyId);
            #endregion

            bool viaSms         = account.Via.HasFlag(Tab_Contact.Communication.Sms);
            bool viaEmail       = account.Via.HasFlag(Tab_Contact.Communication.Email);
            bool viaAlwaysEmail = account.Via.HasFlag(Tab_Contact.Communication.AlwaysEmail);

            string userRole = "Aspirant";
            if (account.Accesslevel >= Server.Level_Admin)
            {
                userRole = "Admin";
            }
            else if (account.Accesslevel >= Server.Level_Reciever)
            {
                userRole = "Benutzer";
            }
            else if (account.Accesslevel > 0)
            {
                userRole = "Beobachter";
            }

            Dictionary <string, string> pairs = new Dictionary <string, string>
            {
                { "##readonly##", isAdmin ? string.Empty : "readonly" },
                { "##disabled##", isAdmin ? string.Empty : "disabled" },
                { "##Id##", account.Id.ToString() },
                { "##Name##", account.Name },
                { "##Accesslevel##", account.Accesslevel.ToString() },
                { "##UserRole##", userRole },
                { "##UserAccesslevel##", user.Accesslevel.ToString() },
                { "##CompanyId##", account.CompanyId.ToString() },
                { "##CompanyName##", company.Name },
                { "##CompanyCity##", System.Text.RegularExpressions.Regex.Replace(company.City, @"\d", "") },
                { "##viaEmail##", viaEmail ? "checked" : string.Empty },
                { "##viaAlwaysEmail##", viaAlwaysEmail ? "checked" : string.Empty },
                { "##Email##", account.Email },
                { "##viaPhone##", viaSms ? "checked" : string.Empty },
                { "##Phone##", "+" + account.Phone.ToString() },
                { "##MaxInactiveHours##", account.MaxInactiveHours.ToString() },
                { "##KeyWord##", account.KeyWord },
                { "##CompanyList##", isAdmin ? Tab_Company.SelectCompanyAllToHtmlOption(account.CompanyId) : string.Empty },

                { "##NewContact##", isAdmin ? Html.ButtonNew("account") : string.Empty },
                { "##DeleteContact##", isAdmin ? Html.ButtonDelete("account", account.Id) : string.Empty }
            };

            string form  = Server.Page(Server.Html_FormAccount, pairs);
            string tabel = Html.FromTable(dt, true, "account");

            await Server.PageAsync(context, "Benutzerkonto", tabel + form);
        }