Exemplo n.º 1
0
        public ActionResult Create(AccountModel accountModel)
        {
            try
            {
                var        accountDBModel = new AccountDBModel();
                TB_ACCOUNT account        = new TB_ACCOUNT();
                account.S_ACCOUNT       = accountModel.account;
                account.S_PASSWORD      = accountModel.password;
                account.S_FULLNAME      = accountModel.fullName;
                account.S_PHONE         = accountModel.phone;
                account.S_ADDRESS       = accountModel.address;
                account.S_TECHNICAL     = accountModel.technical;
                account.D_BIRTHDAY      = accountModel.birthDay;
                account.S_TYPE          = accountModel.type == 0 ? "employee" : "manager";
                account.N_STORE_ID      = accountModel.storeId;
                account.N_DEPARTMENT_ID = accountModel.departmentId;
                accountDBModel.createAccount(account);

                return(RedirectToAction("List"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public TB_ACCOUNT getAccountById(int id)
        {
            object[] sqlParams =
            {
                new SqlParameter("@N_ID", id)
            };
            TB_ACCOUNT result = context.Database.SqlQuery <TB_ACCOUNT>("Usp_GetAccountById @N_ID", sqlParams).SingleOrDefault();

            return(result);
        }
Exemplo n.º 3
0
        public TB_ACCOUNT getAccount(string account, string password)
        {
            object[] sqlParams =
            {
                new SqlParameter("@S_ACCOUNT",  account),
                new SqlParameter("@S_PASSWORD", password)
            };
            TB_ACCOUNT accountResult = context.Database.SqlQuery <TB_ACCOUNT>("Usp_GetAccountLogin @S_ACCOUNT,@S_PASSWORD", sqlParams).SingleOrDefault();

            return(accountResult);
        }
Exemplo n.º 4
0
        public object updateAccountById(TB_ACCOUNT model)
        {
            object[] sqlParams =
            {
                new SqlParameter("@N_ID",        model.N_ID),
                new SqlParameter("@S_FULLNAME",  model.S_FULLNAME),
                new SqlParameter("@S_PHONE",     model.S_PHONE),
                new SqlParameter("@S_ADDRESS",   model.S_ADDRESS),
                new SqlParameter("@S_TECHNICAL", model.S_TECHNICAL),
                new SqlParameter("@S_PASSWORD",  model.S_PASSWORD)
            };
            var result = context.Database.SqlQuery <object>("Usp_updateAccountById @N_ID,@S_FULLNAME,@S_PHONE,@S_ADDRESS,@S_TECHNICAL,@S_PASSWORD", sqlParams).SingleOrDefault();

            return(result);
        }
Exemplo n.º 5
0
        public object createAccount(TB_ACCOUNT account)
        {
            object[] sqlParams =
            {
                new SqlParameter("@S_ACCOUNT",       account.S_ACCOUNT),
                new SqlParameter("@S_PASSWORD",      account.S_PASSWORD),
                new SqlParameter("@S_TYPE",          account.S_TYPE),
                new SqlParameter("@S_FULLNAME",      account.S_FULLNAME),
                new SqlParameter("@S_PHONE",         account.S_PHONE),
                new SqlParameter("@S_ADDRESS",       account.S_ADDRESS),
                new SqlParameter("@S_TECHNICAL",     account.S_TECHNICAL),
                new SqlParameter("@D_BIRTHDAY",      account.D_BIRTHDAY),
                new SqlParameter("@N_STORE_ID",      account.N_STORE_ID),
                new SqlParameter("@N_DEPARTMENT_ID", account.N_DEPARTMENT_ID)
            };
            var result = context.Database.SqlQuery <object>("Usp_InsertAccount @S_ACCOUNT,@S_PASSWORD,@S_TYPE,@S_FULLNAME,@S_PHONE,@S_ADDRESS,@S_TECHNICAL,@D_BIRTHDAY,@N_STORE_ID,@N_DEPARTMENT_ID", sqlParams).SingleOrDefault();

            return(result);
        }
Exemplo n.º 6
0
        public ActionResult Edit(AccountModel accountModel)
        {
            try
            {
                var        model   = new AccountDBModel();
                TB_ACCOUNT account = new TB_ACCOUNT();
                account.N_ID        = accountModel.id;
                account.S_FULLNAME  = accountModel.fullName;
                account.S_PHONE     = accountModel.phone;
                account.S_ADDRESS   = accountModel.address;
                account.S_TECHNICAL = accountModel.technical;
                account.S_PASSWORD  = accountModel.password;
                model.updateAccountById(account);

                return(RedirectToAction("List"));
            }
            catch
            {
                return(View());
            }
        }