public int CreatePassword(string userId, PasswordCreateModel passwordCreateModel) { string applicationOwner = _applicationData.GetApplicationOwner(passwordCreateModel.ApplicationId); if (applicationOwner != userId) { throw new Exception("Application was not found or user is unauthorized."); } var p = new { UserId = userId, ApplicationId = passwordCreateModel.ApplicationId, PasswordAlias = passwordCreateModel.PasswordAlias, Username = passwordCreateModel.Username, Password = passwordCreateModel.Password, Encrypted = passwordCreateModel.Encrypted }; var output = _sql.SaveData <int, dynamic>("dbo.spPasswordAdd", p, "PMDatabase"); return(output); }