/// <summary>
        /// Updates the account information in the repository.
        /// </summary>
        /// <param name="account">Account to update.</param>
        /// <exception cref="StorageException">
        /// It is thrown out in case of storage problems.
        /// </exception>
        public void UpdateAccount(AccountDal account)
        {
            var item = _accounts.Where(a => a.Number == account.Number).First();

            _accounts.Remove(item);
            _accounts.Add(account);
        }
Exemplo n.º 2
0
        public int login(string username, string password)
        {
            AccountDal login  = new AccountDal();
            var        entity = login.GetEntities(i => i.Username == username);

            if (entity.Count <Account>() == 0)
            {
                //Response.Write("<script>alert('不存在该用户!')</script>");
                return(0);
            }
            foreach (var p in entity)
            {
                if (p.Password.Equals(password))
                {
                    //Response.Write("<script>alert('密码正确!')</script>");
                    //Session["key"] = TextBox1.Text;
                    //Server.Transfer("user.aspx");
                    return(1);
                }
                else
                {
                    //Response.Write("<script>alert('密码错误!')</script>");
                    return(2);
                }
            }
            return(0);
        }
Exemplo n.º 3
0
        public ActionResult Verify(Account account)
        {
            var AccountDal = new AccountDal();
            var username   = account.ID;
            var password   = account.Password;
            var objUser    = (from x in AccountDal.Accounts where x.ID.Equals(username) && x.Password.Equals(password) select x).ToList <Account>();

            try
            {
                switch (objUser[0].Type)
                {
                case "1":
                    return(RedirectToAction("Student", "Student", account));

                case "2":
                    return(RedirectToAction("Lecturer", "Lecturer", account));

                case "3":
                    return(RedirectToAction("Faculty", "Faculty", account));
                }
            }
            catch (Exception)
            {
            }
            ViewBag.ErrorMessage4 = "Worng ID or Password, try again!";
            return(View("Login"));
        }
        /// <summary>
        /// To the BLL account.
        /// </summary>
        /// <param name="accountDal">The account DAL.</param>
        /// <returns>Equal BLL account.</returns>
        public static AccountBll ToBllAccount(this AccountDal accountDal)
        {
            AccountBll temp = FactoryAccounts.CreateAccount(accountDal.Type, accountDal.PersonId, accountDal.Number, accountDal.Balance);

            temp.Person = accountDal.Person.PartialMapPersonBll();

            return(temp);
        }
        /// <summary>
        /// To the DAL account.
        /// </summary>
        /// <param name="accountBll">The account BLL.</param>
        /// <returns>Equal DAL account.</returns>
        public static AccountDal ToDalAccount(this AccountBll accountBll)
        {
            AccountDal temp = new AccountDal(accountBll.PersoneId, accountBll.Number, accountBll.Balance,
                                             accountBll.Point, (int)accountBll.TypeId);

            temp.Person = accountBll.Person.PartialMapPersonDal();

            return(temp);
        }
        /// <summary>
        /// Deletes the specified DTO.
        /// </summary>
        /// <param name="dal">The DAL.</param>
        /// <exception cref="System.ArgumentException">DAL</exception>
        public void Delete(AccountDal dal)
        {
            if (!accounts.Contains(dal))
            {
                throw new ArgumentException($"{nameof(dal)} doesn't contains in the storage");
            }

            accounts.Remove(dal);
        }
Exemplo n.º 7
0
        /// <summary>
        /// To the DAL account.
        /// </summary>
        /// <param name="accountOrm">The account BLL.</param>
        /// <returns>Equal DAL account.</returns>
        public static AccountDal ToDalAccount(this Account accountOrm)
        {
            AccountDal temp = new AccountDal(accountOrm.PersonId, accountOrm.Number, accountOrm.Balance,
                                             accountOrm.Points, accountOrm.TypeId);

            temp.Person = accountOrm.Person.PartialMapPersonDal();

            return(temp);
        }
        /// <summary>
        /// Gets all.
        /// </summary>
        /// <returns>
        /// All accounts from the storage.
        /// </returns>
        public IEnumerable <AccountDal> GetAll()
        {
            foreach (Account account in context.Accounts)
            {
                AccountDal temp = account.ToDalAccount();

                yield return(temp);
            }
        }
        /// <summary>
        /// Creates the specified DTO.
        /// </summary>
        /// <param name="dal">The DTO.</param>
        /// <exception cref="System.ArgumentException">DAL</exception>
        public void Create(AccountDal dal)
        {
            if (accounts.Contains(dal))
            {
                throw new ArgumentException($"{nameof(dal)} already exist");
            }

            accounts.Add(dal);
        }
        /// <summary>
        /// Creates the specified DTO.
        /// </summary>
        /// <param name="dal">The DTO.</param>
        /// <exception cref="ArgumentNullException">DAL</exception>
        public void Create(AccountDal dal)
        {
            if (ReferenceEquals(dal, null))
            {
                throw new ArgumentNullException($"{nameof(dal)} is null");
            }

            Account temp = dal.ToOrmAccount();

            context.Accounts.Add(temp);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Adds a new account to the repository.
 /// </summary>
 /// <param name="account">New account.</param>
 /// <exception cref="StorageException">
 /// It is thrown in the event of a storage error.
 /// </exception>
 public void AddAccount(AccountDal account)
 {
     if (!_accounts.Contains(account))
     {
         _accounts.Add(account);
     }
     else
     {
         throw new StorageException("Account already exists.");
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// A method that removes a account <paramref name="account"/> from the repository.
 /// </summary>
 /// <param name="account">
 /// The Account for removal.
 /// </param>
 /// <exception cref="StorageException">
 /// It is thrown out in case of storage problems.
 /// </exception>
 public void RemoveAccount(AccountDal account)
 {
     if (_accounts.Contains(account))
     {
         _accounts.Remove(account);
     }
     else
     {
         throw new AccountNotFoundException("Account not found.");
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// To the DAL account.
        /// </summary>
        /// <param name="accountBll">The account BLL.</param>
        /// <returns>Equal DAL account.</returns>
        public static AccountDal ToDalAccount(this AccountBll accountBll)
        {
            AccountDal temp = FactoryAccounts.CreateAccount(accountBll.TypeId);

            temp.Valid           = accountBll.Valid;
            temp.Number          = accountBll.Number;
            temp.Balance         = accountBll.Balance;
            temp.Point           = accountBll.Point;
            temp.PersonalInfo.Id = accountBll.PersoneId;

            return(temp);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Partials the map account ORM.
 /// </summary>
 /// <param name="accountDal">The account DAL.</param>
 /// <returns>Current ORM account.</returns>
 internal static Account PartialMapAccountOrm(this AccountDal accountDal)
 {
     return(new Account()
     {
         Number = accountDal.Number,
         Id = accountDal.Id,
         TypeId = accountDal.Type,
         Valid = accountDal.Valid,
         Balance = accountDal.Balance,
         PersonId = accountDal.PersonId,
         Points = accountDal.Point
     });
 }
        /// <summary>
        /// Gets the specified identifier.
        /// </summary>
        /// <param name="number">The number.</param>
        /// <returns>
        /// Current DTO from the storage.
        /// </returns>
        /// <exception cref="ArgumentNullException">Number.</exception>
        public AccountDal Get(int number)
        {
            Account temp = context.Accounts.FirstOrDefault(item => item.Number == number);

            if (ReferenceEquals(temp, null))
            {
                throw new ArgumentNullException($"{nameof(number)} doesn't contains in the database");
            }

            AccountDal result = temp.ToDalAccount();

            return(result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Adds a new account to the repository.
        /// </summary>
        /// <param name="account">New account.</param>
        /// <exception cref="StorageException">
        /// It is thrown in the event of a storage error.
        /// </exception>
        public void AddAccount(AccountDal account)
        {
            if (ReferenceEquals(account, null))
            {
                throw new ArgumentNullException(nameof(account));
            }

            using (var context = new BankAccountContext())
            {
                context.Accounts.Add(account.ToAccountEF());
                context.SaveChanges();
            }
        }
Exemplo n.º 17
0
        public void TestMethod1()
        {
            AccountDal account = new AccountDal();

            account.Insert(new Account {
                UserID = Guid.NewGuid(), Username = "******", Password = "******"
            });
            PersonDal person = new PersonDal();

            person.Insert(new Person {
                PID = Guid.NewGuid(), Pname = "york", Pgrade = "BoardMember", Padvs = "", Pact4fire = "", Pact4water = "", Pcontact = "", Pemail = "", Pfield_of_firm = "", Phobbies = "", Pjob4u = "", Ppro = "", Psex = "男", Ptel = "135", Ptime = 1234567, PwechatID = "", Pwork_years = 1, Username = "******"
            });
        }
        public ActionResult Verify()
        {
            if (ModelState.IsValid)
            {
                AccountDal       dal          = new AccountDal();
                string           username     = Request.Form["Name"].ToString();
                string           userpassword = Request.Form["Password"].ToString();
                List <Account>   acc          = (from x in dal.Users where x.userName == username && x.userPassword == userpassword select x).ToList <Account>();
                AccountViewModel usr          = new AccountViewModel();
                bool             check        = false;
                usr.usersName = acc;
                if (usr.usersName.Count == 0)
                {
                    Session["check"] = "opertion faild name";
                    return(RedirectToAction("Login"));
                }
                else
                {
                    Session["check"] = "opertion";
                    Account login_usr = new Account();
                    login_usr           = usr.usersName[0];
                    Session["Username"] = login_usr.userName;
                    Session["Password"] = login_usr.userPassword;
                    Session["Type"]     = login_usr.userType;
                    Session["ID"]       = login_usr.userID;

                    if (login_usr.userType == "student")
                    {
                        return(View("StudentHomePage", login_usr));
                    }
                    if (login_usr.userType == "faculty")
                    {
                        return(View("FacultyHomePage", login_usr));
                    }
                    if (login_usr.userType == "lecturer")
                    {
                        return(View("LecturerHomePage", login_usr));
                    }
                    else
                    {
                        return(View("Login"));
                    }
                }
            }
            else
            {
                return(View("Login"));
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// To the BLL account.
        /// </summary>
        /// <param name="accountDal">The account DAL.</param>
        /// <returns>Equal BLL account.</returns>
        public static AccountBll ToBllAccount(this AccountDal accountDal)
        {
            AccountBll temp = new AccountBll()
            {
                Id        = accountDal.Id,
                Number    = accountDal.Number,
                PersoneId = accountDal.PersonalInfo.Id,
                Point     = accountDal.Point,
                TypeId    = (int)accountDal.Type,
                Valid     = accountDal.Valid,
                Balance   = accountDal.Balance
            };

            return(temp);
        }
        /// <summary>
        /// Updates the specified DTO.
        /// </summary>
        /// <param name="dal">The DTO.</param>
        /// <exception cref="System.ArgumentException">DAL</exception>
        public void Update(AccountDal dal)
        {
            AccountDal temp = accounts.Find(item => item.Id == dal.Id);

            if (ReferenceEquals(temp, null))
            {
                throw new ArgumentException($"{nameof(dal)} doesn't contains in the storage");
            }

            temp.Balance  = dal.Balance;
            temp.Number   = dal.Number;
            temp.PersonId = dal.PersonId;
            temp.Point    = dal.Point;
            temp.Type     = dal.Type;
        }
Exemplo n.º 21
0
 public static AccountEF ToAccountEF(this AccountDal account)
 {
     return(new AccountEF
     {
         Balance = account.Balance,
         Bonus = account.Bonus,
         FirstName = account.FirstName,
         LastName = account.LastName,
         AccountType = new AccountTypeEF
         {
             Type = account.Type
         },
         AccountId = account.Number
     });
 }
Exemplo n.º 22
0
        /// <summary>
        /// To the BLL account.
        /// </summary>
        /// <param name="accountDal">The account DAL.</param>
        /// <returns>Equal ORM account.</returns>
        public static Account ToOrmAccount(this AccountDal accountDal)
        {
            Account temp = new Account()
            {
                Number   = accountDal.Number,
                Id       = accountDal.Id,
                TypeId   = accountDal.Type,
                Valid    = accountDal.Valid,
                Balance  = accountDal.Balance,
                PersonId = accountDal.PersonId,
                Points   = accountDal.Point,
                Person   = accountDal.Person.PartialMapPersonOrm()
            };

            return(temp);
        }
        /// <summary>
        /// Updates the specified DTO.
        /// </summary>
        /// <param name="dal">The DTO.</param>
        /// <exception cref="ArgumentNullException">DTO is null.</exception>
        /// <exception cref="ArgumentException">DTO.</exception>
        public void Update(AccountDal dal)
        {
            if (ReferenceEquals(dal, null))
            {
                throw new ArgumentNullException($"{nameof(dal)} is null");
            }

            Account temp = context.Accounts.FirstOrDefault(item => item.Id == dal.Id);

            if (ReferenceEquals(temp, null))
            {
                throw new ArgumentException($"{nameof(dal)} doesn't contains in the storage");
            }

            temp = dal.ToOrmAccount();
        }
Exemplo n.º 24
0
        public void TestMethod2()
        {
            AccountDal login  = new AccountDal();
            var        entity = login.GetEntities(i => i.Username == "echo");

            using (StreamWriter writer =
                       new StreamWriter(@"C:\Users\lenovo\Desktop\t.txt", true))
            {
                foreach (var p in entity)
                {
                    writer.WriteLine(p.Username);
                }
            }

            //account.Insert(new Account { Username = "******",Password = "******" });
        }
Exemplo n.º 25
0
        public ECService(string username)
        {
            _persondal = new PersonDal();
            _ecdal     = new XiaoYanDal();
            _memdal    = new XiaoYanDal();
            _account   = new AccountDal();
            var resultp = _persondal.GetEntities(i => i.Username == username);

            foreach (var p in resultp)
            {
                _person = p;
            }
            var resulte = _ecdal.GetEntities(i => i.PID == _person.PID);

            foreach (var e in resulte)
            {
                _ec = e;
            }
        }
Exemplo n.º 26
0
        public ActionResult Verify()
        {
            AccountDal       dal          = new AccountDal();
            string           username     = Request.Form["Name"].ToString();
            string           userpassword = Request.Form["Password"].ToString();
            List <Account>   acc          = (from x in dal.Users where x.UserName == username && x.Password == userpassword select x).ToList <Account>();
            AccountViewModel usr          = new AccountViewModel();

            usr.usersName = acc;
            if (usr.usersName.Count == 0)
            {
                TempData["Message"] = "Login has been failed, username or password does not exist";
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                Account login_usr = new Account();
                login_usr           = usr.usersName[0];
                Session["Username"] = login_usr.UserName;
                Session["Password"] = login_usr.Password;
                Session["Type"]     = login_usr.type;
                Session["ID"]       = login_usr.UserId;

                if (login_usr.type == "Student")
                {
                    return(View("StudentHomePage", login_usr));
                }
                if (login_usr.type == "facultyAdmin")
                {
                    return(View("FacultyHomePage", login_usr));
                }
                if (login_usr.type == "lecturer")
                {
                    return(View("LecturerHomePage", login_usr));
                }
                else
                {
                    return(View("Error", login_usr));
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// A method that removes a account <paramref name="account"/> from the repository.
        /// </summary>
        /// <param name="account">
        /// The Account for removal.
        /// </param>
        /// <exception cref="StorageException">
        /// It is thrown out in case of storage problems.
        /// </exception>
        public void RemoveAccount(AccountDal account)
        {
            if (ReferenceEquals(account, null))
            {
                throw new ArgumentNullException(nameof(account));
            }

            using (var context = new BankAccountContext())
            {
                var accountForRemove = FindAccount(account, context);

                if (ReferenceEquals(accountForRemove, null))
                {
                    throw new AccountNotFoundException();
                }

                context.Accounts.Remove(accountForRemove);

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Deletes the specified DTO.
        /// </summary>
        /// <param name="dal">The DTO.</param>
        /// <exception cref="ArgumentNullException">DTO.</exception>
        /// <exception cref="ArgumentException">DTO.</exception>
        public void Delete(AccountDal dal)
        {
            if (ReferenceEquals(dal, null))
            {
                throw new ArgumentNullException($"{nameof(dal)} is null");
            }

            Account temp = context.Accounts.FirstOrDefault(item => item.Id == dal.Id);

            if (ReferenceEquals(temp, null))
            {
                throw new ArgumentException($"{nameof(dal)} doesn't contains in database");
            }

            if (temp.Balance > 0 || temp.Balance < 0)
            {
                throw new ArgumentException($"{nameof(dal)} can't be close. Its balance doesn't equals 0");
            }

            temp.Valid = false;
        }
Exemplo n.º 29
0
        /// <summary>
        /// Updates the account information in the repository.
        /// </summary>
        /// <param name="account">Account to update.</param>
        /// <exception cref="StorageException">
        /// It is thrown out in case of storage problems.
        /// </exception>
        public void UpdateAccount(AccountDal account)
        {
            if (ReferenceEquals(account, null))
            {
                throw new ArgumentNullException(nameof(account));
            }

            using (var context = new BankAccountContext())
            {
                var accountForUpdate = FindAccount(account, context);

                if (ReferenceEquals(accountForUpdate, null))
                {
                    throw new AccountNotFoundException();
                }

                accountForUpdate.Balance = account.Balance;
                accountForUpdate.Bonus   = account.Bonus;

                context.SaveChanges();
            }
        }
Exemplo n.º 30
0
        public ActionResult MyAccountAction(AccountModel account)
        {
            AccountBal bal = new AccountBal();

            bal.UserId = Convert.ToInt32(Session["loginid"]);
            //bal.AccountNo = account.AccountNo;
            //bal.IfscCode = account.IfscCode;

            AccountDal   dal    = new AccountDal();
            bool         status = dal.MyAccount(bal, out string IFSC, out int Acno);
            AccountModel model  = new AccountModel();

            if (status)
            {
                //bal.AccountNo = account.AccountNo;
                //bal.IfscCode = account.IfscCode;
                model.AccountNo = Acno;
                model.IfscCode  = IFSC;
                model.UserId    = bal.UserId;
            }

            return(View(model));
        }