//them mot tai khoan public bool addNewAccountModel(AccountModel accountModel) { bool result = false; Account account = null; Cart cart = null; Customer customer = customerDAO.save <Customer>(accountModel.Customer); //kiem tra viec them vao co thanh cong hay khong if (customer != null) { //Them tai khoan account = new Account() { UserName = accountModel.UserName, PassWord = accountModel.PassWord, CustomerId = customer.Id }; account = accountDAO.save <Account>(account); //Them gio hang cart = new Cart() { Code = DateTime.Now.Ticks.ToString(), CustomerId = customer.Id }; cart = cartDAO.save <Cart>(cart); } //kiem tra viec them vao co thanh cong hay khong if (account != null && cart != null) { //neu ca 2 them thanh cong result = true; } else { //neu 1 trong 2 khong them thanh cong customerDAO.delete <Customer>(customer); if (account != null) { accountDAO.delete <Account>(account); } else if (cart != null) { cartDAO.delete <Cart>(cart); } } return(result); }