Your Update now knows how to convert to a DTO and how to validate and
update...i think this is a lot of responsibilities for a single method...
I like more having a Translation/Convertion Class which knows both
ways...this helps you doing thinks like list.ConvertAll<AgendtDTO> ... and
inverse...
Gustavo.
On Sun, Oct 5, 2008 at 3:38 PM, codemonkey <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> Just some tips really my current Service update method accepts my
> updateDTO object, uses the repository to do a select of the object by
> ID, maps across the properties and then does an update. Is this a good
> way to do this? or could I be looking at a better way? It works fine I
> am just looking for some constructive criticism.
>
> public void Update(AgentUpdateDTO agentUpdateDTO) {
>
> // Select from the repository by id.
> var agent =
> this.agentRepository.SelectById(agentUpdateDTO.Id);
>
> // Map across properties from DTO.
> agent.Code = agentUpdateDTO.Code;
> agent.Commission = agentUpdateDTO.Commission;
> agent.CompanyName = agentUpdateDTO.CompanyName;
> agent.Enabled = agentUpdateDTO.Enabled;
> agent.FirstName = agentUpdateDTO.FirstName;
> agent.Gender = agentUpdateDTO.Gender;
> agent.Password = agentUpdateDTO.Password;
> agent.Surname = agentUpdateDTO.Surname;
> agent.UserName = agentUpdateDTO.UserName;
> agent.RowVersion = agentUpdateDTO.RowVersion;
>
> if (!string.IsNullOrEmpty(agentUpdateDTO.CountryCode))
> agent.Country =
> this.countryService.SelectByCountryCode(agentUpdateDTO.CountryCode);
>
> // Validate the model and use repository to update.
> agent.Validate();
> this.agentRepository.Update(agent);
>
> }
>
> Cheers
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---