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
-~----------~----~----~----~------~----~------~--~---

Reply via email to