
24 Cal.App.4th 327 (1994)
29 Cal. Rptr.2d 314
RICHARD BRANSON, Plaintiff and Appellant,
v.
SUN-DIAMOND GROWERS OF CALIFORNIA, Defendant and Respondent.
Docket No. C013859.
Court of Appeals of California, Third District.
April 21, 1994.
*331 COUNSEL
Michael F. Babitzke for Plaintiff and Appellant.
Thelen, Marrin, Johnson & Bridges, Janet F. Bentley and Karen A. Henry for Defendant and Respondent.
OPINION
SPARKS, J.
Corporations Code section 317, subdivision (e)(4), permits a court to authorize a corporation to indemnify its agent against a judgment arising from the agent's reasonable and good faith acts on behalf of the corporation. Such an order may be made in "[t]he court in which the *332 proceeding [against the agent] is or was pending...." (Corp. Code, § 317, subd. (e)(4).)
In a different case arising out of proceedings filed in Contra Costa County, the Court of Appeal for the First District held that the agent in question was not entitled to indemnification from the corporation under this statute for an adverse judgment entered against him. (Plate v. Sun-Diamond Growers (1990) 225 Cal. App.3d 1115 [275 Cal. Rptr. 667].) In this case filed in San Joaquin County the agent again seeks indemnification from the corporation, this time on additional claims of contractual rights and equitable estoppel. The question on appeal is whether this present action is barred by the Plate judgment under the doctrines of res judicata and collateral estoppel.
The agent, plaintiff Richard Branson, appeals from a judgment in favor of the corporation, defendant Sun-Diamond Growers of California (Sun-Diamond). The trial court granted Sun-Diamond's motion to dismiss Branson's second amended complaint on the ground that all of his causes of action were barred by the principles of res judicata and collateral estoppel as a result of the decision in Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d 1115.
On appeal, Branson claims for a variety of reasons that the appellate decision in the prior Plate case cannot have res judicata or collateral estoppel effect on those causes of action in his present suit which are unrelated to indemnity under Corporations Code section 317. We agree and therefore reverse the judgment entered in favor of Sun-Diamond.

PROCEDURAL HISTORY
This litigation had its genesis in a lawsuit filed in Contra Costa County in March 1986 by H.R. Plate and H.R. Plate & Company, Inc. (Plate), against Branson, Sun-Diamond, and three other individuals. The litigation resulted in a verdict in favor of Plate and against Branson and another individual for $275,968 but which exonerated Sun-Diamond. Branson then obtained an order in the same proceeding compelling Sun-Diamond to indemnify him against that judgment. Sun-Diamond appealed that order and in a published opinion issued by the Court of Appeal in Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d 1115, the reviewing court reversed the indemnification order. Because that appellate decision is pivotal to this appeal, we quote at length from selected portions of the opinion in the Plate case.
"Sun-Diamond is a corporation owned by four food cooperatives, which serves as an administrative and sales organization for approximately sixty *333 thousand growers who comprise the four cooperatives. Plate is an industrial commodity food broker and was the exclusive broker for Sun-Diamond products in Northern California. Between 1977 and 1985, Plate developed his Sun-Diamond brokerage account from five to one hundred eighteen customers. In late 1984, Plate was the number one Sun-Diamond broker in the United States, measured by volume of business developed and dollar sales.
"McElroy was a sales manager with Sun-Diamond who acted as a liaison between Sun-Diamond management and the brokers. Plate was one of approximately 14 brokers who reported to McElroy. Branson [the plaintiff here] was the industrial marketing manager for all of Sun-Diamond's products.
"Donald Soetaert and James Santo, defendants in the underlying litigation, were Sun-Diamond's vice-president of sales and marketing, and director of sales and marketing for industrial products, respectively. Branson and McElroy reported to Santo.
".... .... .... .... .... .... ....
"Until 1983, Plate had never received any criticism of his brokerage services from anyone at Sun-Diamond. In July 1983, McElroy delivered a letter reprimanding Plate for making sales for competitors of Sun-Diamond. Plate responded to the letter, stating that there were special circumstances justifying each of the sales listed in the letter.
"Because of McElroy's letter, Plate was placed on six months' probation ending January 1984. He successfully cleared the probationary period. At that time, McElroy met with Plate and told him he wanted to become a partner in Plate's business. Plate told him the business was too small.
"In January 1985, McElroy discussed with Plate's son the possibility of his leaving Sun-Diamond and taking the Sun-Diamond account away from Plate. Thereafter, making use of information regarding Plate's accounts to which they had access, Branson and McElroy began planning to establish their own brokerage business. Branson testified that he took a look at Plate's broker profile in February 1985, once he began considering going into the brokerage business.
".... .... .... .... .... .... ....
"In the latter part of May 1985, McElroy and Branson told Santo for the first time that they were going into the brokerage business and asked if *334 Sun-Diamond would appoint them as its industrial brokers for Northern California. After Branson and McElroy gave Sun-Diamond a firm departure date, Santo and Soetaert discussed the benefits and detriments of replacing Plate. They decided that McElroy and Branson would be better representatives for Sun-Diamond in Northern California, as they had more knowledge of the products than any other brokers Santo and Soetart knew. In addition, they did not want Branson and McElroy working for the competition.
"On June 6, 1985, Santo terminated Plate. Branson and McElroy remained at Sun-Diamond until June 28, 1985. In July 1985, Branson and McElroy began their brokerage business with Sun-Diamond as their only account." (Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d at pp. 1119-1121.)
These events led to litigation by Plate. As the Plate court further recounted, "On March 21, 1986, Plate initiated [the Contra Costa suit] against Sun-Diamond, McElroy, Branson, Santo, and Soetaert. The first amended complaint stated a cause of action against Sun-Diamond for breach of contract; causes of action against McElroy and Branson for intentional interference with contract and intentional interference with prospective economic advantage; and causes of action against all defendants for conspiracy to induce breach of contract and conspiracy to interfere with prospective economic advantage.
"[I]n June 1986, it was determined that counsel for Sun-Diamond would undertake representation of all five defendants, and Sun-Diamond would bear the costs of litigation. Branson and McElroy inquired as to who would be responsible for an adverse judgment rendered against them. Counsel for Sun-Diamond responded with a letter stating that Sun-Diamond would indemnify them to the extent required by [Corporations Code] section 317 against liabilities arising from the litigation.
"The case proceeded to jury trial. Following the submission of the case to the jury, the jury returned a special verdict exonerating Sun-Diamond, Santo, and Soetaert as against all claims, but finding Branson and McElroy liable for intentional interference with contract, intentional interference with prospective economic advantage, and conspiracy to interfere with prospective economic advantage. The jury awarded damages against these two defendants in the amount of $275,968. On February 8, 1988, a judgment was entered accordingly.
"Following the entry of judgment, Branson and McElroy sought indemnification from Sun-Diamond against the judgment. On April 27, 1988, the Sun-Diamond board of directors advised them that Sun-Diamond declined to *335 indemnify. Branson and McElroy then filed a motion for indemnification pursuant to [Corporations Code] section 317, subdivision (e)(4)." (Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d at p. 1121.)
In their amended memorandum of points and authorities in support of their motion for indemnification pursuant to Corporations Code section 317, Branson and McElroy[1] pointed out "parallel theories including theories under Labor Code 2802, express indemnification and promissory estoppel to illustrate the fairness of the application of [C]orporation[s] Code 317. Since these parallel theories would have to be presented by a formal complaint in a separate action, they are presented in this motion solely for purpose of demonstrating the good faith and equity of indemnification."
Turning again to the Plate decision, the court continued: "Following a hearing, the trial court ordered indemnification, stating in its written decision: `The motion of defendants Branson and McElroy for indemnification is granted. [¶] The Court finds each of said defendants was an agent of Sun Diamond within the meaning of Section 317 of the Corporations Code, and each acted in good faith and in a manner each believed to be [in] the best interests of the corporation.'" (Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d at pp. 1121-1122.)
Sun-Diamond appealed from the order granting indemnification to Branson and McElroy. While that appeal was pending, Branson filed the present case in San Joaquin County against Sun-Diamond and its attorneys. His second amended complaint alleged causes of action against Sun-Diamond for breach of an express written contract to indemnify him pursuant to Corporations Code section 317; for breach of an oral contract of indemnity; for breach of an implied-in-fact agreement of indemnity; for breach of a duty to indemnify under Labor Code section 2802; for breach of duty to indemnify under Corporations Code section 317; for breach of the duty of good faith and fair dealing; and for equitable estoppel. Sun-Diamond demurred to all of the causes of action of this complaint on the ground, among others, that there was another action pending on the same cause of action. (Code Civ. Proc., § 430.10, subd. (c).) The trial court sustained the demurrer on that ground without leave to amend.[2] The trial court also granted Sun-Diamond's motion to strike the claim for punitive damages in the sixth cause *336 of action for breach of the covenant of good faith and fair dealing under the authority of Foley v. Interactive Data Corp. (1988) 47 Cal.3d 654 [254 Cal. Rptr. 211, 765 P.2d 373]. The court then entered an interlocutory judgment abating the proceedings until the Plate case then pending on appeal in the First District was finally determined.
On November 30, 1990, the Court of Appeal issued its opinion in the Plate proceeding. The reviewing court reversed the order of indemnification. It held that the Contra Costa trial court had erred in ordering Sun-Diamond to indemnify Branson and McElroy pursuant to Corporations Code section 317, subdivision (b), because the court's implied finding that these employees were sued "by reason of the fact" they were agents of the corporation and its express finding that they acted in good faith were not supported by substantial evidence. "The record establishes these defendants [Branson and *337 McElroy] were sued because of activity undertaken to establish their own business entirely independent of Sun-Diamond, for their own personal benefit, and not in furtherance of Sun-Diamond's policies or objectives. Such activity was unrelated to the performance of their corporate duties and responsibilities at Sun-Diamond.... Branson and McElroy thus were sued in their capacity as individuals pursuing their personal interests, and not by reason of the fact they were agents of Sun-Diamond. There simply is no evidence to support a finding that the first prerequisite to indemnification under section 317, subdivision (b), was met." (Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d at p. 1126.)
Continuing, the Plate court noted that "[t]he remaining prerequisites to indemnification, that the agent acted in good faith and with a reasonable belief that the activity was in the best interests of the corporation, allow for indemnification even where the agent was negligent or committed some error. [Citation.] [¶] The statute, however, prohibits indemnification in cases of bad faith or intentional wrongdoing, ... [¶] Of course, if the corporate agent is acquitted of any wrongdoing, he or she has a right to indemnification for legal expenses incurred for his or her defense, even though he or she was initially charged with bad faith or intentional misconduct. [Citation.] [¶] If the agent is not vindicated, he or she may still seek indemnification, provided the good faith requirement can be met." (Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d at p. 1124.) As to this second prerequisite of good faith, the court ruled that "... the jury's finding that the conduct giving rise to the action consisted of intentional wrongdoing committed against a third party precludes a finding that Branson and McElroy acted in good faith." (Id. at p. 1126.)
The Plate court also concluded that the letter from the corporation to Branson and McElroy did not establish an obligation to indemnify them independent of the requirements of the statute. "The argument of Branson and McElroy that Sun-Diamond is bound to indemnify them, regardless of whether the requirements of section 317 were met, must therefore fail." (Plate v. Sun-Diamond Growers, supra, 225 Cal. App.3d at pp. 1122-1128.)
Following the issuance of the opinion in Plate, Branson filed a motion in this case to terminate the plea in abatement and to amend his complaint.[3] Sun-Diamond responded by opposing the motion to amend the complaint and by requesting a dismissal of action. Sun-Diamond argued that the order sustaining the demurrer to the second amended complaint without leave to *338 amend prohibits Branson from proceeding on that complaint. Furthermore, so its argument went, the Plate decision adversely resolved all Branson's claims in his proposed third amended complaint and consequently the principles of res judicata and collateral estoppel preclude him from proceeding on that proposed complaint. The trial court granted the motion to terminate the plea in abatement, denied the motion to amend the complaint and then entered judgment in favor of Sun-Diamond. This appeal by Branson followed.

DISCUSSION
Branson contends that the appellate decision has no res judicata effect because some of his causes of action were not based upon the "same right or obligation" as those he asserted in the Plate litigation. Branson concedes that the Plate judgment controls his statutory right to indemnity under Corporations Code section 317 and hence bars his first and fifth causes of action based upon that statute. He further concedes that his fourth cause of action under Labor Code section 2802 is also barred under principles of res judicata.[4] But he argues the remaining causes of action are not precluded under the principles of res judicata. As he sees it, these causes of action are "based upon an oral agreement, implied in fact agreement, and the doctrine of estoppel. All of the contract theories, expressed or implied, and the estoppel theory, focus on what rights and obligations of the parties arise out of the representations made by the parties as distinguished from obligations imposed by law. Accordingly, the relief sought in the above-entitled matter was not based upon the `same right or obligation' since the right sought to be enforced in the instant matter is contractual or quasi-contractual as distinguished from the statutory right or rights arising under Corporations Code § 317." Branson further contends that the portion of the Plate opinion dealing with contractual indemnity was dicta and thus cannot have preclusive effect because the issue of contractual obligation to indemnify was not submitted for determination in the Plate litigation, and that in any event the issues could not be properly determined in the "abbreviated" posttrial statutory motion for indemnification.
*339 Sun-Diamond retorts that Branson has already litigated and lost the claims he now asserts in this action. In its view, "[t]he present action is based on the same alleged `right' to indemnification or `obligation' of Sun-Diamond to indemnify that Branson unsuccessfully asserted in the Plate litigation." Consequently, the trial court correctly ruled that Branson is barred by the Plate decision from relitigating his claimed entitlement to indemnification from Sun-Diamond for his intentional wrongdoing. We conclude Branson has the better argument.
Branson's principal claim on appeal is that the doctrines of res judicata and collateral estoppel do not apply because his present complaint alleges different rights than those asserted in the Plate litigation. The present complaint, he emphasizes, seeks to enforce rights which are "contractual or quasi-contractual as distinguished from the statutory right or rights arising under Corporations Code § 317."
We turn then to that statute. Corporations Code section 317, subdivision (b), provides in relevant part: "A corporation shall have power to indemnify any person who was or is a party or is threatened to be made a party to any proceeding (other than an action by or in the right of the corporation to procure a judgment in its favor) by reason of the fact that the person is or was an agent of the corporation, against expenses, judgments, fines, settlements, and other amounts actually and reasonably incurred in connection with the proceeding if that person acted in good faith and in a manner the person reasonably believed to be in the best interests of the corporation...." If the agent has been successful on the merits in defense of such a proceeding, "... the agent shall be indemnified against expenses actually and reasonably incurred by the agent in connection therewith." (Corp. Code, § 317, subd. (d).) If the agent is not successful, "... any indemnification under this section shall be made by the corporation only if authorized in the specific case, upon a determination that indemnification of the agent is proper in the circumstances because the agent has met the applicable standard of conduct set forth in subdivision (b) or (c), by any of the following: ... [¶] (4) The court in which the proceeding is or was pending upon application made by the corporation or the agent or the attorney or other person rendering services in connection with the defense, whether or not the application by the agent, attorney or other person is opposed by the corporation." (Corp. Code, § 317, subd. (e)(4).)
This statute sets the stage for the play of the doctrine of res judicata in this case. The doctrine is said by the Restatement Second of Judgments to have three main components: "... merger  the extinguishment of a claim in a judgment for plaintiff [citation]; bar  the extinguishment of a claim in a *340 judgment for defendant [citation]; and issue preclusion  the effect of the determination of an issue in another action between the parties on the same claim (direct estoppel) or a different claim (collateral estoppel)." (Rest.2d Judgments, Introductory Note, p. 131.) In California, these three components have been conflated into two and thus res judicata is said to have two aspects, its primary aspect of bar and merger and the secondary aspect of collateral estoppel. (Henn v. Henn (1980) 26 Cal.3d 323, 329-330 [161 Cal. Rptr. 502, 605 P.2d 19].) Thus, "[t]he doctrine of collateral estoppel is one aspect of the concept of res judicata. In modern usage, however, the two terms have distinct meanings. The Restatement Second of Judgments, for example, describes collateral estoppel as `issue preclusion' and res judicata as `claim preclusion.' (Rest.2d Judgments, § 27.)" (Lucido v. Superior Court (1990) 51 Cal.3d 335, 341, fn. 3 [272 Cal. Rptr. 767, 795 P.2d 1223, 2 A.L.R.5th 995].)

A. Res Judicata

We begin our analysis with the claim preclusion or bar feature of res judicata. (1) "In its primary aspect, res judicata operates as a bar to the maintenance of a second suit between the same parties or parties in privity with them on the same cause of action." (People v. Sims (1982) 32 Cal.3d 468, 477, fn. 6 [186 Cal. Rptr. 77, 651 P.2d 321].)[5] On the other hand, if the causes of action in the second proceeding are not the same as those asserted in the prior litigation, then the judgment in the prior proceeding does not constitute a bar to the subsequent proceeding. "Unless the requisite identity of causes of action is established, however, the first judgment will not operate as a bar." (Agarwal v. Johnson (1979) 25 Cal.3d 932, 954 [160 Cal. Rptr. 141, 603 P.2d 58].)
(2) For purposes of identifying a cause of action under the doctrine of res judicata, "California has consistently applied the `primary rights' theory, under which the invasion of one primary right gives rise to a single cause of action." (Slater v. Blackwood (1975) 15 Cal.3d 791, 795 [126 Cal. Rptr. 225, 543 P.2d 593].)[6] But "... the `cause of action' is based upon the harm suffered, as opposed to the particular theory asserted by the litigant. [Citation.] Even where there are multiple legal theories upon which recovery *341 might be predicated, one injury gives rise to only one claim for relief." (Ibid.)
Under the primary rights theory advanced by Pomeroy, "... a cause of action consists of 1) a primary right possessed by the plaintiff, 2) a corresponding primary duty devolving upon the defendant, and 3) a delict or wrong done by the defendant which consists in a breach of such primary right and duty. [Citation.] Thus, two actions constitute a single cause of action if they both affect the same primary right." (Gamble v. General Foods Corp. (1991) 229 Cal. App.3d 893, 898 [280 Cal. Rptr. 457].)
Professor John Norton Pomeroy explained his theory this way: "Every command or rule of the private civil law creates a primary right in one individual, and a primary duty corresponding thereto resting upon another person or number of persons. These rights and duties are, of course, innumerable in their variety, nature, and extent. If a person upon whom a primary duty rests towards another fails to perform that duty, and thereby violates the other's primary right, there at once arise the remedial right and duty. The one whose primary right has been violated immediately acquires a secondary right to obtain an appropriate remedy from the wrong-doer, while the wrong-doer himself becomes subjected to the secondary duty of giving or suffering such remedy.... It is plain from this analysis that the nature and extent of remedial rights and duties, and of the remedies themselves, must depend upon two distinct factors taken in combination, namely, the nature and extent of the primary rights which are violated, and the nature and extent of the wrongs in and by which the violation is effected. The same primary right may be broken by many kinds of wrong-doing; and the same wrongful act or default may invade many different rights." (1 Pomeroy, Equity Jurisprudence (5th ed. 1941) The Constituent Parts of Equity, § 91, p. 120, fn. omitted; see also Pomeroy, Code Remedies (5th rev. ed. 1929) Introduction, § 2, p. 2.)
Consequently, "[i]f the facts alleged show one primary right of the plaintiff, and one wrong done by the defendant which involves that right, the plaintiff has stated but a single cause of action, no matter how many forms or kinds of relief he may claim that he is entitled to, and may ask to recover; the relief is no part of the cause of action." (Pomeroy, Code Remedies, supra, Joinder of Causes of Action, § 349, p. 533.) "On the other hand, if the facts alleged in the pleading show that the plaintiff is possessed of two or more distinct and separate primary rights, each of which has been invaded, or that the defendant has committed two or more distinct and separate *342 wrongs, it follows inevitably, from the foregoing principle, that the plaintiff has united two or more causes of action, although the remedial rights arising from each, and the corresponding reliefs, may be exactly of the same kind and nature. If two separate and distinct primary rights could be invaded by one and the same wrong, or if the single primary right should be invaded by two distinct and separate legal wrongs, in either case two causes of action would result; a fortiori must this be so when the two primary rights are each broken by a separate and distinct wrong." (Op. cit. supra, § 350, p. 535.)
The application of this theory can best be illustrated by reviewing several representative cases. In Slater v. Blackwood, supra, 15 Cal.3d 791, for example, the minor plaintiff was injured in an automobile accident while riding as a guest. In 1970, he sued the driver and the owner for damages, framing his complaint in light of California's then existing "guest statute" permitting limited recovery for injuries resulting from intoxication or willful misconduct. (See Veh. Code, § 17158.) Nonsuit was granted and that adverse judgment was affirmed on appeal. After the high court later held the guest statute unconstitutional as applied to an injured nonowner guest, the minor filed another lawsuit over the same accident, this time seeking recovery on a negligence theory. The issue on appeal was whether the 1970 judgment was res judicata and hence constituted a bar to the second suit. The Slater court held that it was. "The `primary right' alleged to have been violated in the instant case is plaintiff's right to be free from injury to her person. [Citations.] It is clearly established that `... there is but one cause of action for one personal injury [which is incurred] by reason of one wrongful act.'" (Slater v. Blackwood, supra, 15 Cal.3d at p. 795.)
Similarly, in Bay Cities Paving & Grading, Inc. v. Lawyers' Mutual Ins. Co. (1993) 5 Cal.4th 854 [21 Cal. Rptr.2d 691, 855 P.2d 1263], the high court held that only one primary right had been violated. There plaintiff's attorney recorded a mechanic's lien but negligently failed to serve a stop notice on the lenders and thereafter negligently failed to file a complaint to foreclose the lien. These two acts of legal malpractice, the court ruled, deprived the client of only one primary right. The plaintiff "had one primary right  the right to be free of negligence by its attorney in connection with the particular debt collection for which he was retained. He allegedly breached that right in two ways, but it nevertheless remained a single right." (Id. at p. 860.)
On the other hand, different primary rights may be violated by the same wrongful conduct. This distinction was drawn in Agarwal v. Johnson, supra, 25 Cal.3d 932. There the question was whether a judgment in favor of defendants in a civil rights action brought by plaintiff under title VII of the Civil Rights Act of 1964 (42 U.S.C. § 2000e et seq.) was res judicata in *343 plaintiff's subsequent action for defamation and intentional infliction of emotional distress. The high court held it was not. The court acknowledged that "[u]nder the `primary rights' theory adhered to in California, ... there is only a single cause of action for the invasion of one primary right." (25 Cal.3d at p. 954.) But "Title VII," the court pointed out, "vests employees with independent federal statutory rights against discriminatory employment practices. It does not supplant state remedies." (Id. at p. 955.) On the other hand, "[d]efamation and intentional infliction of emotional distress are specifically recognized as potentially available causes of action under state law." (Ibid.) It follows that the adverse determination in the federal title VII proceeding does not operate as a bar to the state action predicated upon different primary rights, even though the claims arose under the same general set of facts. "While the federal action was based on the same underlying facts as the instant case, it does not follow that the federal judgment is res judicata." (Id. at p. 954.)
The same point was made in Craig v. County of Los Angeles (1990) 221 Cal. App.3d 1294 [271 Cal. Rptr. 82]. There the question was whether a prior mandate proceeding to compel the sheriff's office to comply with the civil service commission's order to hire plaintiff barred the present action for fraud, intentional infliction of emotional distress and employment discrimination. The Craig court held it did not. "Here, the primary right in the mandate actions involved the right to be employed as a harbor patrol officer. The later action to recover damages because of the denial of that right involves a different primary right." (Id. at pp. 1301-1302.) The court emphasized that the "... mandate proceedings were instituted to enforce appellant's right to employment as a harbor patrol officer. The issue of past salary or damages was not tendered or considered in that action. Only now, when appellant seeks recovery for the harm which resulted in the respondents' wrongful conduct, are these issues raised." (Id. at p. 1302.)
(3) It follows from this theory and these illustrative cases that the primary right to seek authorization for indemnity under Corporations Code section 317 is not the same cause of action as one for breach of a contract for indemnity (whether oral or implied in fact or of the implied term of good faith and fair dealing) or one asserted under the doctrine of equitable estoppel. The statute merely accords agents of corporations the right to seek authorization for indemnity against adverse judgments rendered against them for their reasonable and good faith acts on behalf of the corporation. Contractual indemnity, in contrast, accords the contracting party a right to indemnity pursuant to the terms of the contract. Similarly, breach of implied covenant of good faith and fair dealing gives rise to contract remedies and in addition, to tort remedies when the breaching party also "seeks to shield *344 itself from liability by denying, in bad faith and without probable cause, that the contract exists." (Seaman's Direct Buying Service, Inc. v. Standard Oil Co. (1984) 36 Cal.3d 752, 768-769 [206 Cal. Rptr. 354, 686 P.2d 1158].) Finally, a cause of action for equitable estoppel "arises from declarations or conduct of the party estopped." (11 Witkin, Summary of Cal. Law (9th ed. 1990) Equity, § 177, p. 858.)
We hold therefore that Branson's application for an order under Corporations Code section 317 involves a different primary right than those asserted in these causes of action.
(4) Besides constituting a different cause of action, there is another reason why the judgment in the former case cannot act as a bar to these causes of action in the present case. As the Restatement Second of Judgments instructs, the bar of res judicata does not apply where "[t]he plaintiff was unable to rely on a certain theory of the case or to seek a certain remedy or form of relief in the first action because of the limitations on the subject matter jurisdiction of the courts or restrictions on their authority to entertain multiple theories or demands for multiple remedies or forms of relief in a single action, and the plaintiff desires in the second action to rely on that theory or to seek that remedy or form of relief." (Rest.2d Judgments, § 26, subd. (1)(c), pp. 233-234.) This point is illustrated in Roberts v. Redlich (1952) 111 Cal. App.2d 566 [244 P.2d 933]. There a landlord sued for damages caused by defendant tenant's holding over after the termination of his lease. The tenant claimed a judgment for damages in an unlawful detainer action barred the present action. Rejecting this claim, the court noted that damages in the unlawful detainer action under the circumstances were limited to those which occurred during the detention and up to trial. The damages awarded in the present case in contrast were limited to the period following the trial. "Such damages were not recoverable in the former action. The judgment rendered in the former action did not operate as a bar to the recovery of the damages awarded in the present action." (Id. at p. 570.)
By the same token, Branson's contractual claims or his claim for equitable estoppel were not recoverable on a motion under Corporations Code section 317. He had not filed a complaint or cross-complaint against Sun-Diamond alleging those causes of action in the Plate litigation. Needless to say, in the absence of such a pleading, those causes of action were not before the court. Consequently, the trial court was limited to making the requisite findings *345 and determinations under Corporations Code section 317 in response to Branson's motion.[7]
(5) Finally, there is an even more compelling reason why the determination of the motion under Corporations Code section 317 is not res judicata on the causes of action under examination in the present suit  namely, the statute itself. Subdivision (g) of the statute expressly declares that it does not "affect any right to indemnification to which persons other than directors and officers may be entitled by contract or otherwise." (Corp. Code, § 317, subd. (g).)[8] By its very terms, the statute declares that the granting or denying of relief under it has no preclusive effect on any other legal right Branson may have for indemnity. Hence the Legislature has made the policy decision that whatever similarities there may be between applications under Corporations Code section 317 and other causes of action for indemnity, the proceedings under that section will not have a preclusive effect on related actions for indemnity. (See Gikas v. Zolin (1993) 6 Cal.4th 841, 851 [25 Cal. Rptr.2d 500, 863 P.2d 745].)
For all of these reasons we conclude that the judgment in the Plate litigation does constitute a bar under res judicata to those causes of action at issue in Branson's second amended complaint.

B. Collateral Estoppel

Having determined that there was no claim preclusion or bar to the causes of action at issue, we next examine whether the judgment in prior cases, by operation of collateral estoppel, would nevertheless be fatal to those causes *346 of action by defeating some indispensable element. Although a second action between the parties on a different cause of action is not barred by res judicata, nevertheless "... the first judgment `operates as an estoppel or conclusive adjudication as to such issues in the second action as were actually litigated and determined in the first action.' [Citations.]" (7 Witkin, Cal. Procedure (3d ed. 1985) Judgment, § 253, p. 691, italics in original, quoting Todhunter v. Smith (1934) 219 Cal. 690, 695 [28 P.2d 916].)
(6a) "In general, collateral estoppel precludes a party from relitigating issues litigated and decided in a prior proceeding." (Gikas v. Zolin, supra, 6 Cal.4th at p. 848.) "Traditionally, we have applied the doctrine only if several threshold requirements are fulfilled. First, the issue sought to be precluded from relitigation must be identical to that decided in a former proceeding. Second, this issue must have been actually litigated in the former proceeding. Third, it must have been necessarily decided in the former proceeding. Fourth, the decision in the former proceeding must be final and on the merits. Finally, the party against whom preclusion is sought must be the same as, or in privity with, the party to the former proceeding." (Lucido v. Superior Court, supra, 51 Cal.3d at p. 341.)
Consequently, "... a former judgment is not a collateral estoppel on issues which might have been raised but were not; just as clearly, it is a collateral estoppel on issues which were raised, even though some factual matters or legal arguments which could have been presented were not." (7 Witkin, op. cit. supra, § 257, p. 696, italics in original.)
(7a) Branson challenges only the first requirement of collateral estoppel. He argues that the issue of whether Sun-Diamond, by its deeds, acts and words, contractually committed itself to provide his indemnification is entirely separate from his statutory right to indemnity under Corporations Code section 317. He asserts that the issues of contractual indemnity, breach of the covenant of good faith and fair dealing, and equitable estoppel were not, and could not, have been litigated in the unique posttrial statutory motion procedure contemplated by section 317 of the Corporations Code. Once again we agree.
As relevant to this case, the issues under Corporation Code section 317 were whether Branson (1) is or was an agent of Sun-Diamond; (2) was a party to the Plate litigation "by reason of the fact that [he] is or was an agent of the corporation"; (3) actually and reasonably incurred expenses or suffered a judgment in connection with that litigation; and (4) "acted in good faith and in a manner [he] reasonably believed to be in the best interests of the corporation...." (Corp. Code, § 317, subd. (b).) The Plate court held *347 that Branson was not sued because he was an agent of the corporation but rather was joined as a party defendant because he was pursuing his own personal interests. It further held that Branson had not acted in good faith.
Neither of these issues, being sued by reason of the fact he was an agent of Sun-Diamond or acting in good faith and in a manner reasonably believed to be in the best interests of Sun-Diamond, has any relevance to Branson's causes of action for breach of an oral contract for indemnity or for an implied-in-fact agreement to indemnify.
The cause of action for breach of an oral agreement alleged that "Sun-Diamond has breached the oral contract entered into with [Branson] to indemnify [him] from any loss or expenses as a result of the lawsuit brought by H.R. Plate in exchange for their assistance." "To recover on a contract of indemnity against liability it is sufficient for the indemnitee to set forth in his complaint the fact that judgment has been rendered against him, the amount of judgment, the breach of the indemnitor's obligation to hold the indemnitee harmless as agreed, and the amount of the judgment unpaid." (14 Cal.Jur.3d, Contribution & Indemnification, § 65, p. 728.)
The cause of action for breach of an implied-in-fact contract alleged there was such an agreement "wherein Sun-Diamond would indemnify [Branson] from any harm, expenses, costs, or liabilities, arising out of the litigation commenced by H.R. Plate." The only distinction between an express contract and an implied-in-fact contract is whether the terms are stated in words or expressed by conduct. "An express contract is one, the terms of which are stated in words." (Civ. Code, § 1620.) In contrast, "[a]n implied contract is one, the existence and terms of which are manifested by conduct." (Civ. Code, § 1621.) Thus, as Witkin notes, "[t]he distinction between express and implied in fact contracts relates only to the manifestation of assent; both types are based upon the expressed or apparent intention of the parties." (1 Witkin, Summary of Cal. Law (9th ed. 1987) Contracts, § 11, p. 46, italics in original.) Neither the issue of agency or that of good faith is relevant, much less dispositive, to these contractual causes of action.
The cause of action for breach of the covenant of good faith and fair dealing alleged that "[i]n failing to provide indemnification to [Branson] and in failing to consider or even interview [Branson] for reinstatement as a broker with Sun-Diamond, Sun-Diamond has breached the duty of good faith and fair dealing implied in every contract in California. Sun-Diamond has further, in bad faith, denied the existence of the Contract, which denial has resulted in damages to [Branson]." Whether in his dealing with Plate, Branson acted in good faith and in the best interests of Sun-Diamond is an *348 entirely different question than the issue of whether Sun-Diamond, having entered into an indemnity contract with Branson in exchange for his cooperation, thereafter breached an implied term of that contract of good faith and fair dealing. Nothing in the Plate decision was preclusive on that separate and distinct issue.
Finally, in his cause of action for equitable estoppel, Branson alleged that "Sun-Diamond should be equitably estopped from refusing to provide indemnification to [him]. Such conduct, in addition to the general allegations incorporated, include[s] representing to [Branson] [he] would be indemnified while knowing that such indemnification was dependent on the outcome of the litigation and the discretion of the Sun-Diamond Board. Sun-Diamond intended that [Branson] rely on [its] representations of indemnification and [Branson] did so rely." (8) Equitable estoppel arises from the declarations or conduct of the party estopped and has five elements: "(a) a representation or concealment of material facts (b) made with knowledge, actual or virtual, of the facts (c) to a party ignorant, actually and permissibly, of the truth (d) with the intention, actual or virtual, that the latter act upon it; and (e) the party must have been induced to act upon it." (11 Witkin, Summary of Cal. Law, Equity, op. cit. supra, § 177, p. 859, italics omitted; see also Evid. Code, § 623.) Neither of the two issues actually litigated in the Plate case are material to this cause of action.
Since the two issues actually litigated in the Plate case are not fatal to these causes of action, the doctrine of collateral estoppel does not furnish a ground for dismissing Branson's complaint and entering a judgment in favor of Sun-Diamond.
The fact that the appellate court addressed the question of indemnity based on matters independent of Corporations Code section 317 does not change this result. As we have explained, the issues relating to contractual indemnity and equitable estoppel were not before the Plate court. As a result, its statements on those matters were dicta and have no res judicata effect on the subsequent litigation. (6b) In order for collateral estoppel to apply the issue in question "must have been necessarily decided in the former proceeding." (Lucido v. Superior Court, supra, 51 Cal.3d at p. 341.) Consequently, "[w]hen determination of an issue was entirely unnecessary to the former judgment, it will not have collateral estoppel effect." (First N.B.S. Corp. v. Gabrielsen (1986) 179 Cal. App.3d 1189, 1196 [225 Cal. Rptr. 254]; see also County of Santa Clara v. Deputy Sheriffs' Assn. (1992) 3 Cal.4th 873, 879, fn. 7 [13 Cal. Rptr.2d 53, 838 P.2d 781].)
(7b) Because the Plate judgment has no res judicata or collateral estoppel effect on the causes at issue in the present case, the judgment in favor of Sun-Diamond predicated upon those theories must be reversed.


*349 DISPOSITION
The judgment is reversed and the cause remanded to the trial court with directions to set aside its order sustaining Sun-Diamond's demurrer without leave to amend to the second, third, sixth and seventh causes of action of Branson's second amended complaint, and enter a new and different order overruling the demurrer to those causes of action. Branson shall recover his costs on appeal.
Puglia, P.J., and Blease, J., concurred.
NOTES
[1]  According to Branson's brief, Robert McElroy died before the appeal in the Plate case was determined. In any event, McElroy is not a party to this appeal.
[2]  Code of Civil Procedure section 430.10, subdivision (c), permits a demurrer to be filed on the ground that "[t]here is another action pending between the same parties on the same cause of action." Section 430.70 further permits a demurrer to be filed "based on a matter of which the court may take judicial notice pursuant to Section 452 or 453 of the Evidence Code." Consequently, in demurring on the ground of another action pending, "... the defendant may go beyond the face of the complaint by specifying matter of which the court may take judicial notice." (5 Witkin, Cal. Procedure (3d ed. 1985) Pleading, § 921, p. 359.)

As Witkin also notes, "[t]he pendency of another action is classified as one of the pleas in abatement or dilatory pleas, and, as such, it is `not favored.'" (5 Witkin, Cal. Procedure, op. cit. supra, § 921 at p. 358, italics in original.) Among other things, this disfavor is expressed in the rule that "... the demurrer should not be sustained without leave to amend and the action should not be dismissed." (Ibid.)
Code of Civil Procedure section 597 provides in relevant part that where "a demurrer based upon subdivision (c) of Section 430.10 is sustained (and no other special defense is sustained) an interlocutory judgment shall be entered in favor of the defendant pleading the same to the effect that no trial of other issues shall be had until the final determination of that other action, ..." In Lord v. Garland (1946) 27 Cal.2d 840 [168 P.2d 5], the court explained the function of such a judgment: "The purpose of the interlocutory judgment ... is to permit the trial court to retain jurisdiction over the subsequent action so that when a final determination is had in the prior pending action the court will be empowered to determine the issues in the subsequent suit. If a judgment upon the merits is rendered in the suit first commenced, the party asserting the plea in abatement should be granted leave to amend to plead the res judicata effect of the judgment in bar of the subsequent action. But if, as in the present case, the prior litigation is not determined upon the merits, the trial court should hear and decide the rights of the parties in accordance with the issues presented by the pleadings in the second action." (Id. at p. 851, italics added.)
Thus, in this case, the trial court erroneously sustained the demurrer without leave to amend. It is also questionable whether the defense of res judicata can now be raised by a motion to dismiss supported by declarations or affidavits. Although earlier cases upheld that procedure (see, e.g., Olwell v. Hopkins (1946) 28 Cal.2d 147, 152-153 [168 P.2d 972]; McKenna v. Elliott & Horne Co. (1953) 118 Cal. App.2d 551, 554 [258 P.2d 528]), later cases have held that speaking motions to dismiss have been superseded by the summary judgment statute. (See, e.g., Lavine v. Jessup (1957) 48 Cal.2d 611, 614 [311 P.2d 8]; Pianka v. State of California (1956) 46 Cal.2d 208, 211 [293 P.2d 458]; see generally, 5 Witkin, Cal. Procedure, Pleading, op cit., supra, §§ 955-957 at pp. 386-393.) It may well be that the trial court erroneously permitted Sun-Diamond to raise the issue of res judicata by a motion to dismiss rather than by a motion for summary judgment or by an amendment of its answer to plead the res judicata effect of the first judgment.
[3]  Branson's proposed third amended complaint is identical to the second amended complaint except that it deleted reference to Robert McElroy, dropped the law firm as defendants, deleted the causes of action for breach of an express contract to indemnify under Corporations Code section 317 and for breach of the duty to indemnify under that section, and added a cause of action for declaratory relief.
[4]  Labor Code section 2802 provides that "[a]n employer shall indemnify his employee for all that the employee necessarily expends or loses in direct consequence of the discharge of his duties as such, or of his obedience to the directions of the employer, even though unlawful, unless the employee, at the time of obeying such directions, believed them to be unlawful."

Branson concedes that "although 2802 of the Labor Code was not expressly considered by the Appellate Court the finding by the Appellate Court that at the time of the conduct which gave rise to liability, Branson was acting outside the scope of his employment would be res judicata as to Branson in the event he attempted to assert a cause of action under § 2802 of the Labor Code."
[5]  As the Restatement Second of Judgments phrases it, "[a] valid and final personal judgment rendered in favor of the defendant bars another action by the plaintiff on the same claim." (Rest.2d Judgments, § 19, p. 161.)
[6]  In Nakash v. Superior Court (1987) 196 Cal. App.3d 59 [241 Cal. Rptr. 578], the appellate court suggested that in determining what constitutes the "`same controversy'" for purposes of res judicata, "[a]nalysis has shifted from identification of a primary right upon which only one claim is allowed to determination of the existence of a transaction involving a nucleus of facts upon which only one claim is allowed." (Id. at p. 68.) Wherever this perceived shift may have occurred, it is inconsistent with the controlling authority of the California Supreme Court and we therefore decline to apply a "nucleus of facts" test.
[7]  Corporations Code section 317, subdivision (b), the subdivision at issue in the Plate litigation, provides that in the appropriate circumstances a corporation "shall have power to indemnify" an agent. From this language it would appear that subdivision (b) empowers, but does not obligate, the corporation to provide indemnity and that the determination under Corporations Code section 317, subdivision (e)(4), is that the corporation has the authority to, and not that it must, indemnify the agent. In litigation under an earlier version of this statute, the Court of Appeal concluded that subdivision (b) provides for permissive rather than mandatory indemnity, and reversed a trial court order which would have compelled the corporation to provide indemnity under that subdivision. (American Nat. Bank & Trust Co. v. Schigur (1978) 83 Cal. App.3d 790, 793 [148 Cal. Rptr. 116].) To the extent that subdivision (b) is viewed as permissive rather than mandatory, Branson's arguments on appeal apply with even greater force. However, since we agree with his position regardless of whether indemnity under Corporations Code section 317, subdivision (b), is mandatory or merely permissive, we need not resolve the extent of a trial court's power to order indemnity in the circumstances presented by this case.
[8]  With respect to directors and officers, subdivision (g) of this statute provides that the indemnity is not exclusive of other rights of indemnification which are authorized in the articles of incorporation. It does not appear that Branson was a director or officer of the corporation.
