Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="register"></param>
 /// <returns></returns>
 public string Put([FromBody] object register)
 {
     if (register == null)
     {
         return("");
     }
     try
     {
         LoginLite   currRegister = (LoginLite)Helpers.JsonDesrialize(register.ToString(), typeof(LoginLite));
         UserContext dbUser       = new UserContext();
         User        usr          = dbUser.AddUser(currRegister.k, currRegister.p, currRegister.n);
         if (usr != null)
         {
             usr.Rst = 1;
             var output = Helpers.JsonSerialize(usr);
             //setCookie(currLogin.k);
             //var loginresult = "{\"rst\": \"s\", \"k\": \"" + usr.Key + "\",\"n\": \"" + usr.Name + "\"}";
             return(output);
         }
         return(Helpers.JsonSerialize(new Payload()
         {
             Rst = 0
         }));
     }
     catch (Exception ex)
     {
         return(Helpers.JsonSerialize(new Payload()
         {
             Rst = -1
         }));
     }
 }
Exemplo n.º 2
0
 public ActionResult <int> Post(CreateUserRequest request)
 {
     if (request != null)
     {
         User user = new User(request.FirstName, request.LastName, request.Email);
         return(_userContext.AddUser(user));
     }
     return(0);
 }
Exemplo n.º 3
0
        // POST api/homes
        public void Post(User uData)
        {
            _USContext = new UserContext();

            uData.FirstName = !string.IsNullOrWhiteSpace(uData.FirstName) ? uData.FirstName.Trim() : string.Empty;
            uData.LastName  = !string.IsNullOrWhiteSpace(uData.LastName) ? uData.LastName.Trim() : string.Empty;

            _USContext.AddUser(uData);
        }
Exemplo n.º 4
0
 public ActionResult Create(UserModel useradd)
 {
     if (Session["matric"] != null && Session["pass"] != null)
     {
         UserContext usc = new UserContext();
         usc.AddUser(useradd);
         return(RedirectToAction("index"));
     }
     return(RedirectToAction("index", "Admin"));
 }
Exemplo n.º 5
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text == "")
            {
                lblValidUsername.Text = "Username cannot be empty";
                return;
            }
            else
            {
                lblValidUsername.Text = "";
            }

            string username = txtUsername.Text;

            User user = uc.GetUser(username);

            if (user != null)
            {
                lblValidUsername.Text = "Username is taken";
                return;
            }
            else
            {
                lblValidUsername.Text = "";
            }

            if (txtPassword.Text == "")
            {
                lblValidPassword.Text = "Password cannot be empty";
                return;
            }
            else
            {
                lblValidPassword.Text = "";
            }

            string password = txtPassword.Text;

            string role = "Customer";

            if (rbtAdmin.Checked)
            {
                role = "Admin";
            }

            user          = new User();
            user.UserName = username;
            user.Password = password;
            user.Role     = role;

            uc.AddUser(user);

            Response.Redirect("/login.aspx");
        }
        private void buttonOk_Click(object sender, EventArgs e)
        {
            user         createdUser = new user();
            data_of_user userData    = new data_of_user();

            createdUser.Login        = textBoxLogin.Text.Trim();
            createdUser.data_of_user = userData;
            userData.user            = createdUser;
            createdUser.Admin        = Convert.ToBoolean(checkBoxAdmin.CheckState);
            userData.Surname         = textBoxSurname.Text.Trim();
            userData.Name            = textBoxName.Text.Trim();
            userData.Patronymic      = textBoxPatronymic.Text.Trim();
            userData.Passport_series = textBoxPassSer.Text.Trim();
            userData.Passport_number = textBoxPassNum.Text.Trim();


            UserCreatingForm creatingForm = new UserCreatingForm(createdUser);

            if (creatingForm.ShowDialog() == DialogResult.OK)
            {
                PasswordForm passForm = new PasswordForm(createdUser.Login);
                if (passForm.ShowDialog() == DialogResult.OK)
                {
                    string pass = passForm.textBoxPassword.Text.Trim();
                    if (pass != null)
                    {
                        createdUser.Password = pass;
                        if (userContext.AddUser(createdUser))
                        {
                            textBoxLogin.Clear();
                        }
                        checkBoxAdmin.CheckState = CheckState.Unchecked;
                        textBoxSurname.Clear();
                        textBoxName.Clear();
                        textBoxPatronymic.Clear();
                        textBoxPassSer.Clear();
                        textBoxPassNum.Clear();
                        MessageBox.Show("User added!");
                    }
                    else
                    {
                        MessageBox.Show("A password is not entered!!! User addition canceled!");
                    }
                }
                else
                {
                    MessageBox.Show("User addition canceled!");
                }
            }
        }
Exemplo n.º 7
0
        public ActionResult SignupDB(User user)
        {
            if (ModelState.IsValid)
            {
                User u = new User();
                u.username   = user.username;
                u.email      = user.email;
                u.password   = Helper.MyEncrypt(user.password);
                ViewBag.user = u;

                db.AddUser(u);
                return(RedirectToAction("Index", "Dashboard"));
            }
            return(RedirectToAction("Signup", "MyAccount"));
        }
Exemplo n.º 8
0
        public void AddUser(Message msg)
        {
            var fullname   = GetLastMessage(msg, States.FullName).MessageText;
            var username   = GetLastMessage(msg, States.Username).MessageText;
            var password   = GetLastMessage(msg, States.Password).MessageText;
            var mobile     = GetLastMessage(msg, States.Mobile).MessageText;
            var telegramId = GetLastMessage(msg, States.TelegramId).MessageText;
            var newUser    = new TelegramUser()
            {
                FullName     = fullname,
                Username     = username,
                Password     = password,
                Mobile       = mobile,
                TelegramId   = telegramId,
                RegisterDate = DateTime.Now,
                IsActive     = true
            };

            using (var db = new UserContext())
            {
                db.AddUser(newUser);
            }
        }