Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active Aug 29, 2015
Embed
What would you like to do?
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