private void AddAccount()
        {
            PdbAccount account = new PdbAccount();

            try
            {
                account = GetInfomation();
                new Accounts(new EmployeeManagementDBContext())
                {
                }.Create(account);
                new EmployeeManagement_Service.Service.Basic.Notification.SuccessfulNotification()
                {
                }.InsertSuccessful();
            }
            catch
            {
                new EmployeeManagement_Service.Service.Basic.Notification.ErrorNotification()
                {
                }.ErrorWhileInsert();
            }
            finally
            {
                GetAllData();
            }
        }
예제 #2
0
        public bool Delete(Guid id)
        {
            PdbAccount account = _context.PdbAccounts.SingleOrDefault(admin => admin.IDAccount == id);

            _context.PdbAccounts.DefaultIfEmpty(account);
            _context.Entry(account).State = System.Data.Entity.EntityState.Deleted;
            return(_context.SaveChanges() == 1);
        }
예제 #3
0
 public void SetUp()
 {
     account                 = new PdbAccount();
     account.AccountName     = "test1";
     account.AccountPassword = "******";
     account.AccountLevel    = "NS";
     account.IDAccount       = Guid.NewGuid();
     account.IDStaff         = new Guid("CFACFF13-F9D6-44D4-8ADE-F5B22FB627C1");
     account.isActive        = true;
 }
 public void SetUp()
 {
     account                 = new PdbAccount();
     account.AccountName     = "test1";
     account.AccountPassword = "******";
     account.AccountLevel    = "NS";
     account.IDAccount       = Guid.NewGuid();
     account.IDStaff         = new Guid("5a1c6fe2-c0b3-4939-ab6f-0b6e0b534775");
     account.isActive        = true;
 }
예제 #5
0
        public PdbAccount GetAccountwithUPD(string username, string password, string department)
        {
            PdbAccount ac    = GetAccountwithUP(username, password);
            PdbStaff   staff = this._context.PdbStaffs.SingleOrDefault(st => st.ID_Staff == ac.IDStaff);

            if (staff.Department == department)
            {
                return(ac);
            }
            return(null);
        }
예제 #6
0
        public void Test_Xoa_TK()
        {
            account                 = new PdbAccount();
            account.AccountName     = "testdelete";
            account.AccountPassword = "******";
            account.AccountLevel    = "NS";
            account.IDAccount       = new Guid("E82BD1A2-0B52-4E34-90E8-42EC7D2C5F78");
            account.IDStaff         = new Guid("CFACFF13-F9D6-44D4-8ADE-F5B22FB627C1");
            account.isActive        = true;
            bool checkdetele = new Accounts(new EmployeeManagementDBContext())
            {
            }.Delete(account.IDAccount);

            Assert.AreNotEqual(checkdetele, false);
        }
예제 #7
0
        public void Test_Update_TK()
        {
            account                 = new PdbAccount();
            account.AccountName     = "testupdate";
            account.AccountPassword = "******";
            account.AccountLevel    = "Bao Ve";
            account.IDAccount       = new Guid("7B17E386-AA4B-496E-89A7-5585FF9480CE");
            account.IDStaff         = new Guid("CFACFF13-F9D6-44D4-8ADE-F5B22FB627C1");
            account.isActive        = true;
            bool checkupdate = new Accounts(new EmployeeManagementDBContext())
            {
            }.Update(account);

            Assert.AreNotEqual(checkupdate, false);
        }
        public void DeleteAccount()
        {
            account                 = new PdbAccount();
            account.AccountName     = "testdelete";
            account.AccountPassword = "******";
            account.AccountLevel    = "NS";
            account.IDAccount       = new Guid("6BDD9FE6-C182-4A51-9B2D-4B92ADBB620A");
            account.IDStaff         = new Guid("B5DAF9C8-AC90-49CA-A742-B419AFAB01B5");
            account.isActive        = true;
            bool checkdetele = new Accounts(new EmployeeManagementDBContext())
            {
            }.Delete(account.IDAccount);

            Assert.AreNotEqual(checkdetele, false);
        }
        public void UpdateAccount()
        {
            account                 = new PdbAccount();
            account.AccountName     = "testupdate";
            account.AccountPassword = "******";
            account.AccountLevel    = "Bao Ve";
            account.IDAccount       = new Guid("6378A0EC-BD76-4230-88D5-6DBCB441A9E7");
            account.IDStaff         = new Guid("B5DAF9C8-AC90-49CA-A742-B419AFAB01B5");
            account.isActive        = true;
            bool checkupdate = new Accounts(new EmployeeManagementDBContext())
            {
            }.Update(account);

            Assert.AreNotEqual(checkupdate, false);
        }
 private PdbAccount GetInfomationforEdit(PdbAccount ac)
 {
     ac.IDStaff         = (Guid)cbb_firstname.SelectedValue;
     ac.AccountName     = txt_accountname.Text;
     ac.AccountPassword = txt_accountpassword.Text;
     ac.AccountLevel    = txt_accountlevel.Text;
     //ac.PdbStaff = new Staffs(new EmployeeManagementDBContext()) { }.GetStaff((Guid)cbb_firstname.SelectedValue);
     if (cb_isactiveaccount.Checked)
     {
         ac.isActive = true;
     }
     else
     {
         ac.isActive = false;
     }
     return(ac);
 }
예제 #11
0
 public PdbAccount CheckLogin(string username, string password, string department)
 {
     if (username == "" || password == "" || department == "")
     {
         if (username == "")
         {
             Error.UsernameRequired();
             return(null);
         }
         else if (password == "")
         {
             Error.PasswordRequired();
             return(null);
         }
         else
         {
             Error.DepartmentRequired();
             return(null);
         }
     }
     else
     {
         try
         {
             PdbAccount ac = new PdbAccount();
             ac = AccountService.GetAccountwithUPD(username, password, department);
             bool checkauthentication = ac.isActive;
             if (checkauthentication)
             {
                 Successful.LoginSuccessful();
                 return(ac);
             }
             else
             {
                 Error.LockedAccount();
                 return(null);
             }
         }
         catch
         {
             return(null);
         }
     }
 }
예제 #12
0
 public bool Update(PdbAccount account)
 {
     this._context.PdbAccounts.Attach(account);
     this._context.Entry(account).State = System.Data.Entity.EntityState.Modified;
     return(_context.SaveChanges() == 1);
 }
예제 #13
0
 public bool Create(PdbAccount account)
 {
     this._context.PdbAccounts.Add(account);
     this._context.Entry(account).State = System.Data.Entity.EntityState.Added;
     return(this._context.SaveChanges() == 1);
 }