Exemple #1
0
        public static IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            string username = req.Query["un"].ToString();
            string password = req.Query["pw"].ToString();
            string email    = req.Query["em"].ToString();

            log.LogInformation("AddUser API accessed, Date:" + new DateTime().ToString());
            UserEngine userEngine = new UserEngine();
            bool       result     = userEngine.AddUser(username, password, email);

            return(new OkObjectResult(result.ToString()));
        }
        private void btnReg_Click(object sender, RoutedEventArgs e)
        {
            //try
            //{
            if (Repository.Edit == false)
            {
                if (txtboxLogIn.Text != "" && txtboxMail.Text != "" && passboxPass.Password != "")
                {
                    bool result;
                    var  engine = new UserEngine(txtboxLogIn.Text, passboxPass.Password);

                    if (cmbboxUni.SelectedIndex != -1)
                    {
                        engine.AddUser(txtboxMail.Text, txtboxName.Text, cmbboxUni.SelectedItem.ToString(), out result);
                    }
                    else
                    {
                        engine.AddUser(txtboxMail.Text, txtboxName.Text, "", out result);
                    }

                    if (result)
                    {
                        engine.GetUserData();
                        Search win = new Search();
                        win.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Пользователь с таким логином уже существует!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                        txtboxLogIn.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Введеные не все данные!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                if (txtboxLogIn.Text != "" && txtboxMail.Text != "")
                {
                    var engine = new UserEngine(txtboxLogIn.Text, "");
                    if (cmbboxUni.SelectedIndex != -1)
                    {
                        engine.UpdUserData(txtboxMail.Text, txtboxName.Text, cmbboxUni.SelectedItem.ToString());
                    }
                    else
                    {
                        engine.UpdUserData(txtboxMail.Text, txtboxName.Text, null);
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Введеные не все данные!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("Введеные не все данные!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            //}
        }