示例#1
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);
        }
示例#2
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);
        }