/// <summary>
        /// Handler für Beantragen-Schaltfläche
        /// </summary>
        public IActionResult OnPostBeantragen()
        {
            #region Validierung

            // [Required] wirkt nicht (vgl. https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.1&tabs=visual-studio#mark-page-properties-required), auch nicht mit TryValidateModel(this);
            //daher hilft das nicht: if (!ModelState.IsValid) return Page();

            if (string.IsNullOrEmpty(Name))
            {
                this.ModelState.AddModelError(nameof(Name), "Name darf nicht leer sein!");
            }
            if (string.IsNullOrEmpty(Firma))
            {
                this.ModelState.AddModelError(nameof(Firma), "Firma darf nicht leer sein!");
            }
            if (string.IsNullOrEmpty(EMail))
            {
                this.ModelState.AddModelError(nameof(EMail), "EMail darf nicht leer sein!");
            }
            if (string.IsNullOrEmpty(ClientArt))
            {
                this.ModelState.AddModelError(nameof(EMail), "ClientArt darf nicht leer sein!");
            }
            if (this.Einverstanden != true)
            {
                this.ModelState.AddModelError(nameof(Einverstanden), "Sie müssen einverstanden sein!");
            }

            if (!new System.ComponentModel.DataAnnotations.EmailAddressAttribute().IsValid(EMail))
            {
                this.ModelState.AddModelError(nameof(EMail), "EMail ungültig!");
            }
            if (MailUtil.IsWegwerfadresse(EMail).Result)
            {
                this.ModelState.AddModelError(nameof(EMail), "E-Mail-Domain nicht erlaubt!");
            }

            if (!this.ModelState.IsValid)
            {
                return(Page());
            }
            #endregion

            #region Logik
            // Client via Geschäftslogik registrieren und E-Mail senden

            var c = new Client();
            c.Name     = Name;
            c.Company  = Firma;
            c.EMail    = EMail;
            c.Created  = DateTime.Now;
            c.ClientID = Guid.NewGuid();
            c.Type     = HttpContext.Request.Form["C_Quelle"];;

            HttpContext.Session.SetObject("Client", c);

            string s = this.Request.HttpContext.Connection.RemoteIpAddress + "\n";
            foreach (var v in this.Request.Headers)
            {
                s += v.Key + ":" + v.Value + "\n";
            }

            c.Memo = s;
            var cm = new ClientManager();

            cm.New(c);

            var text =
                $"Sie erhalten nachstehend Ihre personalisierte Client-ID. Bitte beachten Sie, dass eine Client-ID jederzeit widerrufen werden kann, wenn Sie diese missbrauchen! Bitte beachten Sie die Regeln: https://miraclelistbackend.azurewebsites.net/client\n\n" +
                $"Name: {c.Name}\n" +
                $"Firma: {c.Company}\n" +
                $"E-Mail: {c.EMail}\n" +
                (!String.IsNullOrEmpty(c.Type) ? $"Typ: {c.Type}\n" : "") +
                $"Client-ID: {c.ClientID}\n\n" +
                "Sie benötigen eine personalisierte Client-ID, wenn Sie selbst einen Beispiel-Client für das MiracleList-Backend schreiben wollen. Die Client-ID ist als Parameter bei der Login-Operation zu übergeben.\n\nDr. Holger Schwichtenberg, www.IT-Visions.de";

            var e1 = new ITVisions.NetworkUtil.MailUtil().SendMailTollerant("*****@*****.**", EMail, "Client-ID für MiracleList-Backend", text
                                                                            );

            new LogManager().Log(Event.ClientCreated, Severity.Information, EMail, "CreateClientID", "", null, this.Request.HttpContext.Connection.RemoteIpAddress.ToString(), text + "\n\n" + s);

            #endregion

            // Übergabewerte einzeln setzen
            // this.ClientIDModel_EMail = this.EMail;
            // this.ClientIDModel_Name = this.Name;

            // oder serialisieren:
            var result = new ClientIDModelResult()
            {
                Name = this.Name, EMail = this.EMail
            };
            this.ClientIDModel_Result = JsonConvert.SerializeObject(result);

            // Folgeseite aufrufen
            return(RedirectToPage("./" + nameof(ClientIDConfirmationModel).Replace("Model", "")));
        }
示例#2
0
 public void OnGet()
 {
     //(string Name, string EMail) info = (this.Name, this.EMail);
     this.ClientIDModelResult = JsonConvert.DeserializeObject <ClientIDModelResult>(this.ClientIDModel_Result);
 }