public NotificationCollection SaveWaiter(Waiter waiter) { var newPassword = string.Empty; if (waiter.IsTransient()) { newPassword = passwordGenerator.NewPassword(); waiter.UserAccount = UserAccount.Create(waiter.EmailAddress, newPassword); waiter.UserAccount.EncrypPassword(passwordEncryptor); } else { var existingAccount = repository.FindById <Waiter>(waiter.Id); waiter.UserAccount = existingAccount.UserAccount; //Saving a waiter must not overwrite their shifts with null waiter.Shifts = existingAccount.Shifts; } var result = repository.Save(waiter); //If a new waiter was successfully saved if (!result.HasErrors() && newPassword.IsNotNullOrEmpty()) { var msg = string.Format("You have been registered on Shifter. Your password has been set to {0}. You should change it to something you will remember after logging in.", newPassword); //result += EmailManager.SendEmail(waiter.EmailAddress, Config.FromEmailAddress, "Shifter registration", msg); MessagePublisher.PublishComsMessage(msg, "Shifter registration", waiter.EmailAddress); } return(result); }