public UserModel Save(UserModel user, bool updatePassword = false) { var obj = new UserModel(); var hashedPassword = user.Password; if (updatePassword) { var salt = SaltedHash.CreateSalt(user.Email); hashedPassword = SaltedHash.HashPassword(salt, user.Password); } Run(cmd => { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[SaveUser]"; var dtUtc = DateTime.UtcNow; RepositoryHelper.PopulateDefaultParametersDatesAndBy(user); cmd.AddParameter("@email", user.Email); cmd.AddParameter("@city", user.City ?? "Alexandria"); cmd.AddParameter("@country", user.Country ?? "Canada"); cmd.AddParameter("@culture", user.Culture ?? "en-CA"); cmd.AddParameter("@dateModified", dtUtc); cmd.AddParameter("@firstName", user.FirstName ?? ""); cmd.AddParameter("@isActive", user.IsActive); cmd.AddParameter("@isPublic", user.IsPublic); cmd.AddParameter("@isDeleted", user.IsDeleted); cmd.AddParameter("@lastName", user.LastName ?? ""); cmd.AddParameter("@optIn", user.OptIn); cmd.AddParameter("@phoneNumber", user.PhoneNumber ?? ""); cmd.AddParameter("@postalCode", user.PostalCode ?? "K0C1A0"); cmd.AddParameter("@province", user.Province ?? "Ontario"); cmd.AddParameter("@streetName", user.StreetName ?? ""); cmd.AddParameter("@streetNumber", user.StreetNumber ?? ""); cmd.AddParameter("@updatedBy", user.UpdatedBy); cmd.AddParameter("@type", (int)user.Type); cmd.AddParameter("@dateCreated", user.DateCreated); cmd.AddParameter("@id", user.Id); cmd.AddParameter("@password", hashedPassword); cmd.AddParameter("@accessLevel", user.AccessLevel); cmd.AddParameter("@createdBy", user.CreatedBy); using (var reader = cmd.ExecuteReader()) while (reader.Read()) { obj = MapObject(reader); } }); return(obj); }