Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hagbarddenstore/d25dc2e6bf66bdcd7bea to your computer and use it in GitHub Desktop.
Save hagbarddenstore/d25dc2e6bf66bdcd7bea to your computer and use it in GitHub Desktop.
public void Update()
{
try
{
var user = db.Users.SingleOrDefault(x => x.UserId == userId);
if (user == null)
{
throw new UserNotFoundException(userId);
}
// TODO: Validate the email address.
user.EmailAddress = emailAddress;
if (!string.IsNullOrEmpty(password))
{
user.Password = password;
}
user.StoreId = storeId;
user.Role = role;
db.SaveChanges();
}
catch (InvalidOperationException)
{
throw new MultipleUsersFoundException(userId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment