コード例 #1
0
        public ActionResult login(userAccount user)
        {
            string username = Request["username"];
            string Password = Request["Password"];

            if (!(username == "" && Password == ""))
            {
                if (CorrectTemp.DataAccess.DA.adminIsValid(user.username, user.Password))
                {
                    loginSession();
                    return(RedirectToAction("../Home/admin_Index"));
                }
                else if (CorrectTemp.DataAccess.DA.UserIsValid(user.username, user.Password))
                {
                    loginSession();
                    return(RedirectToAction("../Home/Index"));
                }
                else
                {
                    ViewBag.Message = "Fields entered are incorrect. Try again!";
                    return(View("../Account/login"));
                }
            }
            else
            {
                ViewBag.Message = "Please enter valid fields!";
                return(View("../Account/login"));
            }
        }
コード例 #2
0
        public override void initializeData()
        {
            if (Argument != null && Argument is userAccount)
            {
                _userAccount = (Argument as userAccount);
            }

            registerValidationEntry(txtUsername, validationTypes.NotNull, "Username");
            if (_userAccount != null)
            {
                txtUsername.Text = _userAccount.Username;

                chkIsActive.Checked  = _userAccount.userIsActive;
                chkIsAdmin.Checked   = _userAccount.userIsAdmin;
                nmdMaxProjects.Value = _userAccount.maxProjects;

                txtPassword.cueText = "leave empty if you don't want to change it";
            }
            else
            {
                permanentlyDisableControl(chkIsActive);
                chkIsActive.Checked = true;
                registerValidationEntry(txtPassword, validationTypes.NotNull, "Password");
            }
        }
コード例 #3
0
    public static void deleteAccount(userAccount accountToDelete)
    {
        database.sqlStatement deleteSql = new database.sqlStatement();
        deleteSql.connectionString = database.getConnectString();

        /* Delete the Child Cash Flows from every profile */
        foreach (fundingProfile profileToDelete in accountToDelete.profiles)
        {
            deleteSql.query = "DELETE FROM bmw_cash_flow " +
                              "WHERE profile_id = @profile_id ";

            deleteSql.queryParameters.Add("@profile_id", profileToDelete.id);

            database.executeNonQueryOnDatabase(deleteSql);
            deleteSql.queryParameters.Clear();
        }

        /* Delete the Profiles */
        deleteSql.query = "DELETE FROM bmw_funding_profile " +
                          "WHERE account_id = @account_id ";

        deleteSql.queryParameters.Add("@account_id", accountToDelete.id);

        database.executeNonQueryOnDatabase(deleteSql);
        deleteSql.queryParameters.Clear();

        /* Finally Delete the Account */
        deleteSql.query = "DELETE FROM bmw_user_account " +
                          "WHERE id = @id ";

        deleteSql.queryParameters.Add("@id", accountToDelete.id);

        database.executeNonQueryOnDatabase(deleteSql);
    }
コード例 #4
0
        private void updateAccount()
        {
            string newUsername = txtAccountName.Text;

            if (loadedAccount.name == newUsername)
            {
                /* if the "New" name is the same as the old name, don't do anything */
                return;
            }

            if (common.validateNewUsername(newUsername))
            {
                userAccount updatedAccount = new userAccount(loadedAccount.id, newUsername, common.getMainForm().loadedAccount.profiles);

                common.updateAccount(common.getMainForm().loadedAccount, updatedAccount);
                common.getMainForm().loadedAccount = updatedAccount;
                common.getMainForm().refreshDataForAllMdiChildren();
            }
            else
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("The username you have chosen is ALREADY in use,\r\n" +
                                    "please choose a different username\r\n",
                                    "Invalid Username", MessageBoxButtons.OK);
                }
            }
        }
コード例 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            Bank_Mangment_SystemEntities1 dbe = new Bank_Mangment_SystemEntities1();
            decimal b           = Convert.ToDecimal(fromacctxt.Text);
            var     item        = (from u in dbe.userAccounts where u.Account_No == b select u).FirstOrDefault();
            decimal b1          = Convert.ToDecimal(item.balance);
            decimal totalbal    = Convert.ToDecimal(transfertxt.Text);
            decimal transferacc = Convert.ToDecimal(desacctxt.Text);

            if (b1 > totalbal)
            {
                userAccount item2 = (from u in dbe.userAccounts where u.Account_No == transferacc select u).FirstOrDefault();
                item2.balance = item2.balance + totalbal;
                item.balance  = item.balance - totalbal;

                Transfer transfer = new Transfer();
                transfer.Account_No = Convert.ToDecimal(fromacctxt.Text);
                transfer.Name       = nametxt.Text;
                transfer.ToTransfer = Convert.ToDecimal(desacctxt.Text);
                transfer.Date       = DateTime.UtcNow.ToString();
                transfer.balance    = Convert.ToDecimal(transfertxt.Text);

                dbe.Transfers.Add(transfer);
                dbe.SaveChanges();
                MessageBox.Show("Transfer Money Successfully");
            }
        }
コード例 #6
0
    public static void deleteProfileFromAccount(userAccount owningAccount, fundingProfile profileToDelete)
    {
        owningAccount.profiles.Remove(profileToDelete);

        //Database stuff
        database.sqlStatement deleteSql = new database.sqlStatement();
        deleteSql.connectionString = database.getConnectString();

        /* Delete the Child Cash Flows */
        deleteSql.query = "DELETE FROM bmw_cash_flow " +
                          "WHERE profile_id = @profile_id ";

        deleteSql.queryParameters.Add("@profile_id", profileToDelete.id);

        database.executeNonQueryOnDatabase(deleteSql);
        deleteSql.queryParameters.Clear();

        /* Delete the Profile */
        deleteSql.query = "DELETE FROM bmw_funding_profile " +
                          "WHERE id = @id ";

        deleteSql.queryParameters.Add("@id", profileToDelete.id);

        database.executeNonQueryOnDatabase(deleteSql);
    }
コード例 #7
0
ファイル: frmMain.cs プロジェクト: CPS5995/project1
 /// <summary>
 /// Logs the currently loaded Account OUT,
 /// and reverts the App to a pre-login state
 /// </summary>
 public void logOut()
 {
     common.closeAllMdiChildForms(this);
     this.loadedAccount   = null;
     this.rememberMeToken = null;
     rememberMeToolStripMenuItem.Checked = false;
 }
コード例 #8
0
 public updateProject()
 {
     publishProvider       = new List <IPublishProvider>();
     updatePackages        = new List <updatePackage>();
     linkedPublishProvider = new serializableDictionary <string, List <string> >();
     updateLogUser         = new userAccount();
     viewFilter            = new updatePackageViewFilter();
 }
コード例 #9
0
 public ActionResult Edit(int id)
 {
     using (myDbContext db = new myDbContext())
     {
         userAccount u = db.userAccount.FirstOrDefault(x => x.UserID == id);
         ViewData.Model = u;
         return(View());
     }
 }
コード例 #10
0
ファイル: Registro.cs プロジェクト: xG4ST/PROYECTO_OASIS
        private void register_button_Click(object sender, EventArgs e)
        {
            userAccount newAccount = new userAccount();

            newAccount.name_user     = name_textbox.Text.Trim();
            newAccount.account_user  = registeruser_textbox.Text.Trim();
            newAccount.password_user = registerpassword_textbox.Text.Trim();
            newAccount.type_user     = 1;
            confirmpassword_textbox.Text.Trim();

            if (string.IsNullOrEmpty(name_textbox.Text) || string.IsNullOrEmpty(registeruser_textbox.Text) || string.IsNullOrEmpty(registerpassword_textbox.Text) || string.IsNullOrEmpty(confirmpassword_textbox.Text))
            {
                MessageBox.Show("Los campos no pueden quedar vacios", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (registerpassword_textbox.Text != confirmpassword_textbox.Text)
                {
                    MessageBox.Show("Las contraseñas no coinciden, porfavor coloque la misma contraseña en ambos campos", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //newAccount.name_user == name_textbox.Text || newAccount.account_user == registeruser_textbox.Text
                    MySqlConnection conexion = new MySqlConnection("server = 127.0.0.1; database = snack_db; Uid = root; pwd = 2000;");
                    conexion.Open();

                    MySqlCommand compareUser = new MySqlCommand();
                    compareUser.CommandText = "SELECT * FROM user WHERE account_user = @newAccount.account_user AND password_user = @newAccount.password_user";
                    compareUser.Parameters.AddWithValue("@newAccount.account_user", newAccount.account_user);
                    compareUser.Parameters.AddWithValue("@newAccount.password_user", newAccount.password_user);
                    compareUser.Connection = conexion;

                    MySqlDataReader leer = compareUser.ExecuteReader();
                    if (leer.Read())
                    {
                        MessageBox.Show("El usuario ya existe", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        conexion.Close();
                    }
                    else
                    {
                        int resultado = registerNewUserAccount.agregar(newAccount);
                        if (resultado > 0)
                        {
                            MessageBox.Show("Usuario Registrado con Exito!", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //Menu ToMenu = new Menu();
                            //this.Hide();
                            //ToMenu.Show();
                        }
                        else
                        {
                            MessageBox.Show("No se pudo guardar el Usuario", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
コード例 #11
0
        private void button4_Click(object sender, EventArgs e)
        {
            bi.RemoveAt(dataGridView1.SelectedRows[0].Index);
            dbe = new Bank_Mangment_SystemEntities1();
            decimal     a   = Convert.ToDecimal(accnotext.Text);
            userAccount acc = dbe.userAccounts.First(s => s.Account_No.Equals(a));

            dbe.userAccounts.Remove(acc);
            dbe.SaveChanges();
        }
コード例 #12
0
 public ActionResult Delete(int id)
 {
     using (myDbContext db = new myDbContext())
     {
         userAccount u = db.userAccount.Single(x => x.UserID == id);
         db.userAccount.Remove(u);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
コード例 #13
0
 public ActionResult Edit(userAccount u)
 {
     using (myDbContext db = new myDbContext())
     {
         db.userAccount.Attach(u);
         db.Entry(u).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
コード例 #14
0
ファイル: usersController.cs プロジェクト: tylergmorales/HCS
        public ActionResult Create([Bind(Include = "userId,firstName,lastName,hospitalId,roleId,dateCreated,dateUpdated,editedBy")] user user, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                string email = form["email"].ToString();
                if (db.userAccounts.Where(accounts => accounts.userName == email).Count() == 0)
                {
                    //TODO make these two ID assignments db queries to find ID where hospital = "WCTC" and role = account with lowest permissions
                    user.hospitalId  = 1;
                    user.roleId      = 5;
                    user.dateCreated = DateTime.Today;
                    user.dateUpdated = DateTime.Today;
                    user.editedBy    = 1;
                    db.users.Add(user);
                    db.SaveChanges();

                    List <user> userList = db.users.Where(u => u.firstName == user.firstName && u.lastName == user.lastName && u.dateCreated == user.dateCreated).ToList();
                    userAccount uA       = new userAccount();
                    uA.userId       = userList[0].userId;
                    uA.userName     = email;
                    uA.userGuid     = System.Guid.NewGuid();
                    uA.passwordHash = UserAccount.HashSHA1(form["password"] + uA.userGuid);
                    uA.dateCreated  = DateTime.Now;
                    uA.dateUpdated  = DateTime.Now;
                    uA.editedBy     = 1;
                    db.userAccounts.Add(uA);
                    db.SaveChanges();
                    logger.Info("User " + uA.userName + " created");

                    //Get Signed in account
                    try
                    {
                        user account = db.users.Find(UserAccount.GetUserID());
                        //If it's their account and they are lower-tier, they can't edit their hospital or role.
                        if (account.role.title == "Database Adminstrator" || account.role.title == "Instructor")
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        TempData["success"] = "Account " + uA.userName + " created! You may now sign in with limited access. Please see your instructor to have your account activated.";
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                TempData["error"] = "Email already registered. Please sign in.";
                logger.Info("User tried to create an account with already registered email: " + email);
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.hospitalId = new SelectList(db.hospitals, "hospital_id", "name", user.hospitalId);
            ViewBag.roleId     = new SelectList(db.roles, "roleId", "title", user.roleId);
            return(View(user));
        }
コード例 #15
0
        public void loadAccountIntoForm(userAccount accountToLoad)
        {
            this.loadedAccount = accountToLoad;
            this.Text          = "Profiles for Account: " + loadedAccount.name;

            populateFundingProfileListBox(loadedAccount.profiles);
            lbCashFlows.Items.Clear();

            tsslProfileDetailStatus.Text = "Showing: " + loadedAccount.profiles.Count() + " profiles | " +
                                           "Total Cash Flows: " + loadedAccount.getAccountCashFlows().Count();
        }
コード例 #16
0
ファイル: frmReporting.cs プロジェクト: CPS5995/project1
        /// <summary>
        /// takes the passed user account and "loads" it into the form.
        /// Updating the form title and profile list accordingly
        /// </summary>
        /// <param name="accountToLoad"></param>
        public void loadAccountIntoForm(userAccount accountToLoad)
        {
            this.loadedAccount = accountToLoad;
            this.Text          = "Reporting On: " + loadedAccount.name;

            clbReportProfiles.Items.Clear();
            foreach (fundingProfile profile in loadedAccount.profiles)
            {
                clbReportProfiles.Items.Add(profile.name.ToString(), true);
            }
        }
コード例 #17
0
ファイル: usersController.cs プロジェクト: tylergmorales/HCS
        public ActionResult Edit([Bind(Include = "userId,firstName,lastName,hospitalId,roleId,dateCreated,dateUpdated,editedBy")] user user, FormCollection form)
        {
            user account = db.users.Find(UserAccount.GetUserID());

            if (account.role.title == "Database Adminstrator" || account.role.title == "Instructor")
            {
                if (ModelState.IsValid)
                {
                    user        u  = db.users.Find(user.userId);
                    userAccount uA = db.userAccounts.Where(p => p.userId == user.userId).First();
                    uA.userName = form["email"];
                    var password = form["password"];
                    if (form["password"] != "")
                    {
                        uA.passwordHash = UserAccount.HashSHA1(form["password"] + uA.userGuid);
                    }
                    db.Entry(u).CurrentValues.SetValues(user);
                    db.Entry(uA).State = EntityState.Modified;
                    db.SaveChanges();
                    logger.Info("User " + account.firstName + " " + account.lastName + " edited details of " + user.userId + "(" + user.firstName + " " + user.lastName + ")");
                    return(RedirectToAction("Index"));
                }
                ViewBag.hospitalId = new SelectList(db.hospitals, "hospitalId", "name", user.hospitalId);
                ViewBag.roleId     = new SelectList(db.roles, "roleId", "title", user.roleId);
                return(View(user));
            }
            else if (account.userId == user.userId)
            {
                if (ModelState.IsValid)
                {
                    user        u  = db.users.Find(user.userId);
                    userAccount uA = db.userAccounts.Where(p => p.userId == user.userId).First();
                    uA.userName = form["email"];
                    if (form["password"] != null || form["password"] != "")
                    {
                        uA.passwordHash = UserAccount.HashSHA1(form["password"] + uA.userGuid);
                    }
                    db.Entry(u).CurrentValues.SetValues(user);
                    db.Entry(uA).State = EntityState.Modified;
                    db.SaveChanges();
                    logger.Info("User " + account.firstName + " " + account.lastName + " edited details of " + user.userId + "(" + user.firstName + " " + user.lastName + ")");
                    return(RedirectToAction("Index"));
                }
                ViewBag.hospitalId = new SelectList(db.hospitals, "hospitalId", "name", user.hospitalId);
                ViewBag.roleId     = new SelectList(db.roles, "roleId", "title", user.roleId);
                return(View(user));
            }
            else
            {
                logger.Info("User " + account.firstName + " " + account.lastName + " attempted to edit the details of " + user.userId);
                return(RedirectToAction("tempError", "Home"));
            }
        }
コード例 #18
0
 public ActionResult Register(userAccount user)
 {
     if (ModelState.IsValid)
     {
         using (myDbContext db = new myDbContext())
         {
             db.userAccount.Add(user);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.msg = user.FirstName + " Register successful";
     }
     return(View());
 }
コード例 #19
0
        private void button3_Click(object sender, EventArgs e)
        {
            dbe = new Bank_Mangment_SystemEntities1();
            decimal     accountno   = Convert.ToDecimal(accnotext.Text);
            userAccount useraccount = dbe.userAccounts.First(s => s.Account_No.Equals(accnotext));

            useraccount.Account_No  = Convert.ToDecimal(accnotext.Text);
            useraccount.Name        = nametext.Text;
            useraccount.Date        = dateTimePicker1.Value.ToString();
            useraccount.Mother_Name = mothertext.Text;
            useraccount.Father_Name = fathertext.Text;
            useraccount.PhoneNo     = phonetextbox.Text;
            if (maleradio.Checked == true)
            {
                useraccount.Gender = "Male";
            }
            else
            {
                if (femaleradio.Checked == true)
                {
                    useraccount.Gender = "Female";
                }
            }
            if (marriedradio.Checked == true)
            {
                useraccount.martial_status_ = "Married";
            }
            else
            {
                if (unmarriedradio.Checked == true)
                {
                    useraccount.martial_status_ = "UnMarried";
                }
            }
            Image img = pictureBox1.Image;

            if (img.RawFormat != null)
            {
                if (ms != null)
                {
                    img.Save(ms, img.RawFormat);
                    useraccount.Picture = ms.ToArray();
                }
            }
            useraccount.District = districttext.Text;
            useraccount.State    = statetext.Text;
            dbe.SaveChanges();
            MessageBox.Show("Record Updated!");
        }
コード例 #20
0
    public static void updateAccount(userAccount oldAccount, userAccount updatedAccount)
    {
        //TODO
        database.sqlStatement updateSql = new database.sqlStatement();
        updateSql.connectionString = database.getConnectString();

        updateSql.query = "UPDATE bmw_user_account " +
                          "SET username = @username " +
                          "WHERE id = @id ";

        updateSql.queryParameters.Add("@id", oldAccount.id);
        updateSql.queryParameters.Add("@username", updatedAccount.name);

        database.executeNonQueryOnDatabase(updateSql);
    }
コード例 #21
0
    public static void updateProfileOnAccount(userAccount owningAccount, fundingProfile oldProfile, fundingProfile updatedProfile)
    {
        replaceItemInList(owningAccount.profiles, oldProfile, updatedProfile);
        //Database stuff
        database.sqlStatement updateSql = new database.sqlStatement();
        updateSql.connectionString = database.getConnectString();

        updateSql.query = "UPDATE bmw_funding_profile " +
                          "SET profile_name = @profile_name " +
                          "WHERE id = @id ";

        updateSql.queryParameters.Add("@id", oldProfile.id);
        updateSql.queryParameters.Add("@profile_name", updatedProfile.name);

        database.executeNonQueryOnDatabase(updateSql);
    }
コード例 #22
0
        public void loadAccountIntoForm(userAccount accountToLoad)
        {
            this.loadedAccount = accountToLoad;
            this.Text          = "Details for Account: " + loadedAccount.name;

            populateProfilesListBox(loadedAccount.profiles);

            lblTotals.Text = "Total Profiles: " + loadedAccount.profiles.Count() +
                             "\r\n\r\nTotal Cash Flows (income/expenses): " + loadedAccount.getAccountCashFlows().Count() + " (" + loadedAccount.getAllIncomeFlows().Count() + "/" + loadedAccount.getAllExpenseFlows().Count() + ")" +
                             "\r\n\r\nTotal Income: " + loadedAccount.getAllIncomeFlows().Sum(x => x.amount).ToString("C") +
                             "\r\n\r\nTotal Expenses: " + loadedAccount.getAllExpenseFlows().Sum(x => x.amount).ToString("C");

            tsslAccountStats.Text = "Total Profiles: " + loadedAccount.profiles.Count() + " | Total Cash Flows: " + loadedAccount.getAccountCashFlows().Count();

            txtAccountName.Text = loadedAccount.name;
        }
コード例 #23
0
    public static void createNewAccount(userAccount accountToCreate, string password)
    {
        //Database stuff
        database.sqlStatement insertSql = new database.sqlStatement();
        insertSql.connectionString = database.getConnectString();

        insertSql.query = "INSERT INTO bmw_user_account " +
                          "(username,password,email) " +
                          "VALUES " +
                          "(@username,@password,@email)";

        insertSql.queryParameters.Add("@username", accountToCreate.name);
        insertSql.queryParameters.Add("@password", password);
        insertSql.queryParameters.Add("@email", null);

        database.executeNonQueryOnDatabase(insertSql);
    }
コード例 #24
0
    public static void addProfileToAccount(userAccount accountToAddProfile, fundingProfile profileToAdd)
    {
        accountToAddProfile.profiles.Add(profileToAdd);
        //Database stuff
        database.sqlStatement insertSql = new database.sqlStatement();
        insertSql.connectionString = database.getConnectString();

        insertSql.query = "INSERT INTO bmw_funding_profile " +
                          "(id,account_id,profile_name) " +
                          "VALUES " +
                          "(@id, @account_id, @profile_name) ";

        insertSql.queryParameters.Add("@id", profileToAdd.id);
        insertSql.queryParameters.Add("@account_id", accountToAddProfile.id);
        insertSql.queryParameters.Add("@profile_name", profileToAdd.name);

        database.executeNonQueryOnDatabase(insertSql);
    }
コード例 #25
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (maleradioButton.Checked)
            {
                gender = "Male";
            }
            else if (femaleradioButton.Checked)
            {
                gender = "Female";
            }
            else if (otherradioButton.Checked)
            {
                gender = "Other";
            }

            if (marriedradioButton.Checked)
            {
                m_status = "Married";
            }
            else if (unmarriedradioButton.Checked)
            {
                m_status = "UnMarried";
            }
            BSE = new Bank_Mangment_SystemEntities1();
            userAccount acc = new userAccount();

            acc.Account_No = Convert.ToDecimal(accnotext.Text);
            acc.Name       = nametext.Text;
            acc.DOB        = dateTimePicker1.Value.ToString();
            acc.PhoneNo    = phonetext.Text;

            acc.District        = distext.Text;
            acc.State           = comboBox1.SelectedItem.ToString();
            acc.Gender          = gender;
            acc.martial_status_ = m_status;
            acc.Mother_Name     = mothertext.Text;
            acc.Father_Name     = fathertext.Text;
            acc.balance         = Convert.ToDecimal(balancetext.Text);
            acc.Date            = datelbl.Text;
            acc.Picture         = ms.ToArray();
            BSE.userAccounts.Add(acc);
            BSE.SaveChanges();
            MessageBox.Show("FILE SAVED");
        }
コード例 #26
0
        public ActionResult Login(userAccount user)
        {
            using (myDbContext db = new myDbContext())
            {
                var u = db.userAccount.FirstOrDefault(x => x.UserName == user.UserName);
                if (u == null || u.Password != user.Password)
                {
                    //ViewBag.msg = "Wrong UserName or Password!";
                    ModelState.AddModelError("", "Wrong UserName or Password!");
                }
                else
                {
                    Session["UserId"]   = user.UserName;
                    Session["UserName"] = user.UserName;
                    return(Redirect(Url.Action("Index", "Home")));
                }
            }

            return(View());
        }
コード例 #27
0
ファイル: usersController.cs プロジェクト: tylergmorales/HCS
        public ActionResult DeleteConfirmed(int id)
        {
            user account = db.users.Find(UserAccount.GetUserID());

            if (account.role.title == "Database Adminstrator" || account.role.title == "Instructor")
            {
                user        user = db.users.Find(id);
                userAccount uA   = db.userAccounts.Where(u => u.userId == user.userId).First();
                db.users.Remove(user);
                db.userAccounts.Remove(uA);
                db.SaveChanges();
                //logger.Info("User " + account.firstName + " " + account.lastName + " deleted user " + id);
                return(RedirectToAction("Index"));
            }
            else
            {
                logger.Info("User " + account.firstName + " " + account.lastName + " attempted to delete user " + id);
                return(RedirectToAction("tempError", "Home"));
            }
        }
コード例 #28
0
ファイル: usersController.cs プロジェクト: tylergmorales/HCS
        public ActionResult SignIn(FormCollection form, string ReturnUrl)
        {
            using (HITProjectData_Fall17Entities1 db = new HITProjectData_Fall17Entities1())
            {
                var userEmail = form["email"];
                List <userAccount> accountList = db.userAccounts.Where(u => u.userName == userEmail).ToList();

                //Verify list returned an account.
                if (accountList.Any())
                {
                    userAccount uA = accountList[0];

                    string str = UserAccount.HashSHA1(form["password"] + uA.userGuid);

                    if (str == uA.passwordHash)
                    {
                        user user = db.users.Find(uA.userId);
                        FormsAuthentication.SetAuthCookie(uA.userId.ToString(), false);
                        HttpCookie userRoleCookie = new HttpCookie("role");
                        userRoleCookie.Value = user.role.title;
                        Response.Cookies.Add(userRoleCookie);
                        HttpCookie userIdCookie = new HttpCookie("userId");
                        userIdCookie.Value = Convert.ToString(user.userId);
                        Response.Cookies.Add(userIdCookie);
                        if (ReturnUrl != null)
                        {
                            return(Redirect(ReturnUrl));
                        }
                        return(RedirectToAction("Index", "Home"));
                    }
                    TempData["error"] = "Sorry, invalid user credentials. Please try again";
                    ModelState.AddModelError("Password", "Incorrect password");
                }
                else
                {
                    TempData["error"] = "Sorry, an account with that email was not found.";
                    logger.Info("User tried to login with an invalid email: " + userEmail);
                }
            }
            return(View());
        }
コード例 #29
0
        public void testGetAccountCashFlows()
        {
            userAccount    testAccount = new userAccount();
            fundingProfile testProfile = new fundingProfile();
            cashFlow       testFlow    = new cashFlow();

            fundingProfile testProfile2 = new fundingProfile();
            cashFlow       testFlow2    = new cashFlow();

            testFlow.name  = "Test Flow 1";
            testFlow2.name = "Test Flow 2";

            testProfile.cashFlows.Add(testFlow);
            testProfile2.cashFlows.Add(testFlow2);

            testAccount.profiles.Add(testProfile);
            testAccount.profiles.Add(testProfile2);

            Assert.IsTrue(testAccount.getAccountCashFlows().Contains(testFlow));
            Assert.IsTrue(testAccount.getAccountCashFlows().Contains(testFlow2));
        }
コード例 #30
0
        [HttpPost]//post attribute
        public ActionResult register(userAccount user)
        {
            string username = Request["username"];
            string userPwd  = Request["Password"];
            string userAdrs = Request["shippingAddress"];

            if (!(username == "," && userAdrs == "," && userPwd == ","))
            {
                if (CorrectTemp.DataAccess.DA.AddUser(user.userID, user.username, user.shippingAddress, user.CardNumber, user.email, user.Password, user.userType))
                {
                    return(RedirectToAction("../Home/Index"));
                }
                else
                {
                    ViewBag.Message = "There was a problem, register again!";
                    return(View("../Account/login"));
                }
            }
            else
            {
                ViewBag.Message = "Please enter valid fields!";
                return(View("../Account/login"));
            }
        }