Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UI or BO code?
Message
De
25/08/2010 11:56:44
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
25/08/2010 08:56:01
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01478134
Message ID:
01478397
Vues:
21
Hi Frank,

Yes, that is what I meant and I see no reason what you did wouldn't work fine.
Tim

>>>>Tim
>>>
>>>Originally I was planning on saving the changes in a separate table as I thought it was just an audit trail needed, but it definitely makes more sense keeping the changes/history in one table.
>>>
>>>I'm afraid that I need a bit more help with the specifics.
>>>
>>>When you say "do that on the retrieval", what method would you suggest? I was thinking the HookPostGetEvent() would be ideal, but what code do I use in there to create the new entity and return that instead of the one that has already been created?
>>>
>>>Whether or not they save the new record should have no effect on the original record.
>>>
>>>With respect to what I tried that didn't work, can you explain why it didn't? I had used this code:
>>>
>>>
        protected override void HookPostGetEntity(PolicyEntity policyEntity)
>>>        {
>>>            // check if the entity's status is not "Pending"
>>>            if (policyEntity.StatusFK != (int)StatusCode.Pending)
>>>            {
>>>                // if so, then convert the entity to be a "new" record
>>>                this.CallStateChange(mmBusinessState.Adding);
>>>                policyEntity.PolicyPK = Guid.NewGuid();
>>>            }
>>>        }
>>>
>>>then when I saved I got a message about the update statement not affecting any of the expected rows. If I had changed the state to Adding, why was it doing an update and not an Insert?
>>
>>Hi Frank,
>>
>>What is wrong with putting this in your main retrieval method? Do you have a public method that you are calling on your business object to get the specified policy? That method could be self contained with getting the specified entity, checking the status, then creating a new entity with the changes you need and returning it instead. There is no need to use a hook method when you are calling some method to retrieve the entity in the first place. This would work best because you are retrieving a new entity, setting the values and then *It* is the current entity on the business object so you can bind to it normally and save it normally.
>>Tim
>
>Hi Tim,
>
>I have absolutely no opinion about where to put it. The VFP framework I use recommends using hook methods where possible and has a whole heap of them so that is where I first looked.
>
>What do you mean by "my main retrieval method"? Do you mean this:
>
>
        public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
>        {
>            return this.GetEntity("PoliciesSelectByPK",
>                this.CreateParameter("@PolicyPK", policyPK));
>
>        }
>
>If so, I guess something like this is what you are recommending?
>
>
>// get the requested entity
>PolicyEntity oPolicyEntity = this.GetEntity("PoliciesSelectByPK",
>                this.CreateParameter("@PolicyPK", policyPK));
>// check its status
>if (oPolicyEntity.Status == "Pending")
>   {
>      // if it is not Pending then create a new entity, copy the data from the original entity 
>      PolicyEntity oNewPolicyEntity = new PolicyEntity();
>      CopyPolicyEntity(oPolicyEntity, oNewPolicyEntity);
>      // return the new entity
>      return oNewPolicyEntity;
>   }
>else
>   return oPolicyEntity;
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform