Building a Chat Web App With Signal R, Part 2: Listing 2

The PersonHub Update method.

public bool Update(Person updatedPerson)
     bool result = false;

         using (var context = new PersonContext())
             var existingPerson = context.People.FirstOrDefault(x => x.Id == updatedPerson.Id);

             if (existingPerson != null)
                 existingPerson.FirstName = updatedPerson.FirstName;
                 existingPerson.LastName = updatedPerson.LastName;
                 existingPerson.Email = updatedPerson.Email;
                 result = true;
     catch (Exception)
         Clients.Caller.raiseError("Unable to update the Person.");

     return result;

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at

comments powered by Disqus


.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events